重置节计数器后 hyperref 不起作用

重置节计数器后 hyperref 不起作用

我正在使用\documentclass 演讲在本文档中,我有几个未编号的部分(通篇称为单元) 我想在目录中显示,并且这些部分的页码未编号(使用\pagenumbering{gobble})。 MWE 如下:

\documentclass[english,course]{lecture}
\usepackage{blindtext}
\usepackage{enumitem}
\usepackage{lipsum} % Only needed to generate dummy text for sample.tex
%
% First, provide some data about this document
\title{Main title of the lecture}
\subtitle{Subtitle of the lecture}
\shorttitle{Shortened title} % For headers; if undefined, the usual title will be used
\ccode{Code 7.45} % Most of these data are not compulsory
\subject{Subject of the Talk}
\author{Author's name}
% \date{02}{11}{2134}
% \dateend{07}{11}{2134}
\conference{Lecture hall 7}
\place{University of Physics}

\morelink{vhbelvadi.com}
\clearpage
%
% And then begin your document

\begin{document}
\setcounter{page}{1}
\pagenumbering{roman}  %roemische ziffern
\thispagestyle{empty}

% \tableofcontents

\clearpage

%-----------------------------
\setcounter{page}{1}    
\pagenumbering{arabic}
%==========================================
\phantomsection
\pagenumbering{gobble} % 
\section*{\textbf{UNIT $-$ I : Laws of Thermodynamics}}
\thispagestyle{fancy}
\label{sec:unitone}
\addcontentsline{toc}{section}{\textbf{UNIT $-$ I : Laws of Thermodynamics}\nameref{sec:unitone}}
%
% 
\section*{Syllabus}

\begin{itemize}[itemsep=1.0\baselineskip]

\item[$\bullet$] Thermodynamic Description of system: Zeroth Law of thermodynamics and temperature. First law and internal energy, conversion of heat into work, various thermodynamical processes, Applications of First Law: General Relation between $C_p$ \& $C_v$, Work Done during
Isothermal and Adiabatic Processes, Compressibility \& Expansion Coefficient, Reversible \& irreversible processes, Second law \& Entropy, Carnot’s cycle \& theorem, Entropy changes in reversible \& irreversible processes, Entropy temperature diagrams, Third law of thermodynamics, unattainability of absolute zero.
\end{itemize}
\clearpage
% %--------------------------------------------------
\pagenumbering{arabic}
% %--------------------------------------------------
\section{Introduction}
\blindtext[15]
% 
\section{Carnot's cycle}
\blindtext[15]
% 
\clearpage
% 
% =====================
\phantomsection
\pagenumbering{gobble}
\thispagestyle{fancy}
\section*{\textbf{UNIT $-$ II : Thermodynamic Potentials}}
\label{sec:unittwo}
\addcontentsline{toc}{section}{\textbf{UNIT $-$ II : Thermodynamic Potentials}\nameref{sec:unittwo}}
% 
%
\section*{Syllabus}

\begin{itemize}[itemsep=1.0\baselineskip]

\item[$\bullet$] Thermodynamic Potentials: Enthalpy, Gibbs, Helmholtz and Internal Energy functions, Maxwell’s relations \& applications Joule Thompson Effect, Clausius Clapeyron Equation, Expression for ($C_p$,$C_v$ ), $C_p/C_v$, $T\,dS$ equations.
\end{itemize}

\clearpage

% %--------------------------------------------------
\pagenumbering{arabic} % 
\setcounter{section}{0} % section numbers to restart for a new unit
\addtocounter{page}{6} % last page number is 6;; 
% %--------------------------------------------------
\section{Thermodynamic Potentials} % % section number restarts

\blindtext[15]

\vskip7ex
\centering
* * *
%
\end{document}%

每一个单元有几个编号的部分,ToC以页码显示。这些编号的部分1从新单元开始后重新开始。我遇到的问题如下:

  1. 当节计数器从 1 重新启动时,无法hyperref正常工作。类似问题的答案问题没有解决我的问题。

  2. 一旦使用,页码就不连续了\pagenumbering{gobble}。在开始编号部分之前,我使用过,\pagenumbering{arabic}但那会重新开始页码。我发现的一个解决方案是\addtocounter{page}{last page number}在新的编号部分的开头手动添加。有没有比这更好的解决方案?

请提供帮助和建议。

答案1

我不想下载外部课程。所以有些评论没有它

  • 不要使用\pagenumbering{gobble}它来禁止在页面上打印页码。为此请使用页面样式。要么定义特殊样式,要么重新定义普通样式,请参阅 fancyhdr 的文档。

  • 如果重置了节号,则必须确保该节号\theHsection在整个文档中保持唯一(默认情况下为\thesection)。以适当的方式重新定义它。

  • 您不必到处都植入 \phantomsection。hyperref 还会为带星号的部分创建目标。

\documentclass[english,course]{article}
\usepackage{blindtext}

\usepackage{fancyhdr}
\pagestyle{fancy}
%new page style, or redefine plain style see docu
\fancypagestyle{specialstyle}[fancy]{\cfoot{no page number here}}
\fancypagestyle{fancy}{\cfoot{\thepage}}


\RequirePackage[colorlinks,linkcolor=black,urlcolor=black,citecolor=black]{hyperref}

\begin{document}
\pagenumbering{roman}  %roemische ziffern
\thispagestyle{empty}

xxxx
% \tableofcontents

\clearpage
\pagestyle{specialstyle}
\section*{\textbf{UNIT $-$ I : Laws of Thermodynamics}}
...
\section*{Syllabus}
...
\clearpage
\pagestyle{fancy}
\pagenumbering{arabic}

\section{Introduction}
\blindtext[15]

\section{Carnot's cycle}
\blindtext[15]

\clearpage
\pagestyle{specialstyle}

\section*{\textbf{UNIT $-$ II : Thermodynamic Potentials}}

\section*{Syllabus}

\clearpage
\pagestyle{fancy}
\setcounter{section}{0} % section numbers to restart for a new unit
\renewcommand\theHsection{A-\thesection} % something unique

\section{Thermodynamic Potentials} % % section number restarts

\blindtext[15]

\end{document}%

相关内容