第一个 ToC 条目指向错误的位置

第一个 ToC 条目指向错误的位置

看看这段代码:

% Preview source code

%% LyX 2.3.6 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english,14pt]{extarticle}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman}
\setsansfont[Mapping=tex-text]{Times New Roman}
\setmonofont{Anonymous Pro}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=1cm,headheight=1cm,headsep=0.5cm,footskip=1cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{-2}
\setlength{\parindent}{1.27cm}
\usepackage[xetex]{color}
\definecolor{shadecolor}{rgb}{0, 1, 1}
\usepackage{framed}
\usepackage{enumitem}
\usepackage{setspace}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\onehalfspacing
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=false]
 {hyperref}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\newlength{\lyxlabelwidth}      % auxiliary length 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{ragged2e}
\usepackage{indentfirst}
\PassOptionsToPackage{no-math}{fontspec}
\usepackage{mathspec}
\usepackage{titlesec}

\AtBeginDocument{
\setlist[enumerate]{
left=\parindent,
itemindent=2cm,
noitemsep
}
\setlist[itemize]{
left=\parindent,
itemindent=2cm,
noitemsep,
label=\symbol{"2500}
}
}

\renewcommand{\theequation}{\thesection.\arabic{equation}}

\newcounter{subsectioncnt}

\newlength\sectionskip
\setlength{\sectionskip}{\baselineskip}
\addtolength{\sectionskip}{7pt}

\titleformat
{\subsection}
[block]
{\normalsize\bfseries\center}
{}
{0pt}{
\stepcounter{subsectioncnt}
1.\arabic{subsectioncnt}.\hspace{0.5em}
}[]

\titlespacing*{\subsection}{0pt}
{\sectionskip}
{\sectionskip}

\titleformat
{\section}
[block]
{\normalsize\bfseries\center}
{}
{0em}{}[]

\titlespacing*{\section}{0pt}
{\sectionskip}
{\sectionskip}

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage[variant=american]{english}
\begin{document}
\setcounter{page}{0}

\lhead{}

\chead{}

\rhead{}

\cfoot{\uline{Placeholder}}

\renewcommand{\headrulewidth}{0pt}

\begin{Center}\begin{singlespace}

\noindent\begin{minipage}[t]{1\columnwidth}%
\begin{shaded}%
place

holder\end{shaded}%
\end{minipage}

Placeholder

Placeholder

Placeholder

Placeholder

\end{singlespace}\vspace{4\baselineskip}

Placeholder

Placeholder

Placeholder Placeholder Placeholder Placeholder Placeholder Placeholder
Placeholder Placeholder Placeholder Placeholder Placeholder Placeholder
Placeholder Placeholder Placeholder Placeholder Placeholder Placeholder
Placeholder Placeholder Placeholder Placeholder 

Placeholder 

\vspace{6\baselineskip}

\end{Center}\begin{FlushRight}

Placeholder 

Placeholder 

Placeholder 

\vspace{\baselineskip}

Placeholder 

Placeholder 

\end{FlushRight}\pagebreak{}

\setcounter{page}{1}

\cfoot{\thepage}

\section{Behold the list items}

\subsection{Enumerated ones}
\begin{enumerate}
\item A list item.
\item Another list item.
\end{enumerate}

\subsection{Itemized ones}
\begin{itemize}
\item A bit more of list items
\item More of them
\end{itemize}

\section{Behold the end of the document}

The end.

\pagebreak{}

\tableofcontents{}
\end{document}

如果您单击目录中的第一个条目,系统会将您发送到标题页,而不是实际章节。为什么会发生这种情况?我该如何解决?

如果这很重要,我只是尝试使用 LyX/XeLaTeX 组合,看看是否能在合理的时间/努力内获得所需的结果。话虽如此,我对 @ 东西并不十分热衷。

答案1

请记住,只有极少数示例hyperref应作为最后一个包加载。尤其是在之后titlesec

确保hyperref最后加载的包解决了我的问题,Behold the list items目录中的标题跳转到正确的页面。

相关内容