From 49490043714ca87cf534e807c51eaba89f31ba6f Mon Sep 17 00:00:00 2001 From: syvshc Date: Sun, 5 Jun 2022 04:47:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E5=85=BC=E5=AE=B9=202022/05/16=20?= =?UTF-8?q?=E5=89=8D=E7=9A=84=20hyperref=20=E5=A2=9E=E5=8A=A0=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elegantbook.cls | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/elegantbook.cls b/elegantbook.cls index 61b09c8..bc1231e 100644 --- a/elegantbook.cls +++ b/elegantbook.cls @@ -844,10 +844,20 @@ \ifdefstring{\ELEGANT@lang}{cn}{ \ifdefstring{\ELEGANT@scheme}{chinese}{ \newcommand{\xchaptertitle}{第\zhnumber{\arabic{chapter}}章} }{ - \newcommand{\xchaptertitle}{第 \thechapter{} 章}} - \patchcmd{\NR@chapter}% - {\numberline{\thechapter}}{\numberline{\xchaptertitle}}% - {}{\fail} + \newcommand{\xchaptertitle}{第 \thechapter{} 章}} +% Hyperref 2022/05/16's changelog.txt said +% * nameref is loaded always and earlier (issue#235) + \IfPackageAtLeastTF{hyperref}{2022/05/16} + { + \patchcmd{\NR@chapter}% + {\numberline{\thechapter}}{\numberline{\xchaptertitle}}% + {}{\fail} + } + { + \patchcmd{\Hy@org@chapter}% + {\numberline{\thechapter}}{\numberline{\xchaptertitle}}% + {}{\fail} + } } {\newcommand{\xchaptertitle}{\chaptername~\thechapter~}} @@ -1381,9 +1391,17 @@ beforechap\newpage% \setlength{\cftchapnumwidth}{\widthof{\textbf{附录~999}}} \g@addto@macro\appendix{% % recover \thechapter in the \NR@chapter's \numberline - \patchcmd{\NR@chapter} - {\numberline{\xchaptertitle}} - {\numberline{\thechapter}}{}{} + \IfPackageAtLeastTF{hyperref}{2022/05/16} + { + \patchcmd{\NR@chapter}% + {\numberline{\xchaptertitle}}{\numberline{\thechapter}}% + {}{\fail} + } + { + \patchcmd{\Hy@org@chapter}% + {\numberline{\xchaptertitle}}{\numberline{\thechapter}}% + {}{\fail} + } \addtocontents{toc}{% \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% \protect\renewcommand{\protect\cftchapaftersnum}{}%