为兼容 2022/05/16 前的 hyperref 增加判断

This commit is contained in:
syvshc
2022-06-05 04:47:53 +08:00
parent ccb5464463
commit 4949004371

View File

@@ -845,9 +845,19 @@
\ifdefstring{\ELEGANT@scheme}{chinese}{ \ifdefstring{\ELEGANT@scheme}{chinese}{
\newcommand{\xchaptertitle}{\zhnumber{\arabic{chapter}}} }{ \newcommand{\xchaptertitle}{\zhnumber{\arabic{chapter}}} }{
\newcommand{\xchaptertitle}{ \thechapter{} }} \newcommand{\xchaptertitle}{ \thechapter{} }}
\patchcmd{\NR@chapter}% % Hyperref 2022/05/16's changelog.txt said
{\numberline{\thechapter}}{\numberline{\xchaptertitle}}% % * nameref is loaded always and earlier (issue#235)
{}{\fail} \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~}} {\newcommand{\xchaptertitle}{\chaptername~\thechapter~}}
@@ -1381,9 +1391,17 @@ beforechap\newpage%
\setlength{\cftchapnumwidth}{\widthof{\textbf{附录~999}}} \setlength{\cftchapnumwidth}{\widthof{\textbf{附录~999}}}
\g@addto@macro\appendix{% \g@addto@macro\appendix{%
% recover \thechapter in the \NR@chapter's \numberline % recover \thechapter in the \NR@chapter's \numberline
\patchcmd{\NR@chapter} \IfPackageAtLeastTF{hyperref}{2022/05/16}
{\numberline{\xchaptertitle}} {
{\numberline{\thechapter}}{}{} \patchcmd{\NR@chapter}%
{\numberline{\xchaptertitle}}{\numberline{\thechapter}}%
{}{\fail}
}
{
\patchcmd{\Hy@org@chapter}%
{\numberline{\xchaptertitle}}{\numberline{\thechapter}}%
{}{\fail}
}
\addtocontents{toc}{% \addtocontents{toc}{%
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
\protect\renewcommand{\protect\cftchapaftersnum}{}% \protect\renewcommand{\protect\cftchapaftersnum}{}%