我正在使用课堂报告和 hyperref,似乎我在章节方面遇到了问题,尤其是在引入子章节时。在 .pdf 文件中,当我在上一章中添加子章节时,下面列出的 MWE 中的未编号章节 GH 成为上一章未编号章节的一部分。
请帮忙。
我的完整 MWE 如下(抱歉写得太长了):
\documentclass[10pt,a4]{report}
\usepackage[english]{babel}
\usepackage{setspace}
\usepackage{rotating}
\usepackage{multirow}
\usepackage{enumerate}
\usepackage{array,graphicx}
\usepackage[table]{xcolor}
\usepackage{fullpage}
\usepackage{fmtcount}
\usepackage{float}
\usepackage{pifont}
\usepackage{slashbox}
\usepackage{enumitem}
\usepackage{txfonts}
\usepackage{pxfonts}
\usepackage{longtable}
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\usepackage[T1]{fontenc}
\usepackage[left= 7.5em, right= 7.5em, bottom=13em]{geometry}
\usepackage[colorlinks,linktocpage]{hyperref}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
urlcolor = blue, %Colour for external hyperlinks
linkcolor = blue, %Colour of internal links
citecolor = red %Colour of citations
}
\usepackage{tocstyle}
\usepackage{tocloft}
\renewcommand\cftpartdotsep{1}
\renewcommand\cftchapdotsep{1}
\renewcommand\cftsecdotsep{1}
\usetocstyle{standard}
\settocfeature{raggedhook}{\raggedright}
\makeatletter
\newcommand{\thickhline}{%
\noalign {\ifnum 0=`}\fi \hrule height 2pt
\futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 2pt\hskip\tabcolsep}}
\makeatother
\providecommand{\keywords}[1]{\textbf{\textit{Keywords ---}} #1}
\newcommand*\rot{\rotatebox{90}}
%\definecolor{Gray}{gray}{0.9}
%------------------------------------------------------------------------------------------
\usepackage[strict]{changepage}
\usepackage{framed}
\definecolor{formalshade}{rgb}{0.93,0.93,1}
\newenvironment{formal}{%
\def\FrameCommand{%
\hspace{50pt}%
{\color{blue}\vrule width 2pt}%
{\color{formalshade}\vrule width 1pt}%
\colorbox{formalshade}%
}%
\MakeFramed{\advance\hsize-\width\FrameRestore}%
\noindent\hspace{-4.55pt}% disable indenting first paragraph
\begin{adjustwidth}{}{7pt}%
\vspace{2pt}\vspace{2pt}%
}
{%
\vspace{2pt}\end{adjustwidth}\endMakeFramed%
}
\renewcommand{\thesection}{\Alph{section}}
\newcommand{\spheading}[2][4.5em]{
\rotatebox{90}{\parbox{#1}{\raggedright #2}}}
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\rmfamily\LARGE\bfseries\color{black}}
{\chaptertitlename\ \thechapter}{18pt}{\Large}
\usepackage{graphicx}
\usepackage{lscape}
\begin{document}
\doublespacing
\author{\textbf{}}
\title{Report}
\maketitle
\singlespacing
\tableofcontents
\chapter*{AB}
\addcontentsline{toc}{chapter}{AB}
\section{ab1}
\section{ab2}
\subsection{ab21}
\subsection{ab22}
\subsubsection{ab221}
\subsubsection{ab222}
\chapter*{CD}
\addcontentsline{toc}{chapter}{CD}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\section{cd1}
\section{cd2}
\subsection{cd21}
\renewcommand*{\theHsection}{\theHchapter.\the\value{section}}
\chapter*{EF}
\addcontentsline{toc}{chapter}{EF}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\section{ef1}
\section{ef2}
\section{ef3}
\chapter*{GH}
\addcontentsline{toc}{chapter}{GH}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{IJ}
\addcontentsline{toc}{chapter}{IJ}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{KL}
\addcontentsline{toc}{chapter}{KL}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{MN}
\addcontentsline{toc}{chapter}{MN}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{OP}
\addcontentsline{toc}{chapter}{OP}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{RS}
\addcontentsline{toc}{chapter}{RS}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}
\chapter*{TU}
\addcontentsline{toc}{chapter}{TU}
\setcounter{section}{0}
\renewcommand*{\theHsection}{chX.\the\value{section}}\
\end{document}