使用 hyperref 的包钩子来避免包冲突

使用 hyperref 的包钩子来避免包冲突

到目前为止,只有少数包需要在之后加载hyperref。考虑下面的代码,它创建了一个clist包含这些包algorithm1algorithmicarydshlnchappg代码。到目前为止,代码运行良好,在 之后加载这些包hyperref。代码使用doc,它使用了hypdoc很多重新定义等。
代码使用\disable@package@load两个参数,第一个是包名称,第二个,根据手册可用于添加消息。但是它使用 \日志,似乎被忽略了(看起来第二个参数被吞噬了)。我该如何解决这个问题?无论是否使用地图,都会出现这个问题。代码旨在由类加载。

%\listfiles
\documentclass{book}
\usepackage{doc}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\ExplSyntaxOn
\makeatletter
\clist_set:Nn\hyperconflicts{algorithm,algorithmic,arydshln, chappg}
\clist_map_inline:Nn\hyperconflicts{
  \disable@package@load {#1}{\wlog{CONFLICTED~#1~XXXX}\ERROR} %does not work
  \AddToHook{package/hyperref/after}{
    \reenable@package@load{#1}
    \usepackage{#1}
  }
}
\makeatother
\ExplSyntaxOff
%\usepackage{hyperref}
\usepackage{hypdoc}
\hypersetup{colorlinks}
\begin{document}
\tableofcontents
\chapter{One}
\section{algorithm and algorithmic packages}
\IfPackageLoadedTF{algorithm}{T}{F}

\begin{algorithmic} \WHILE{some condition holds} \STATE carry out some processing \ENDWHILE \end{algorithmic}

\section{the arydshln package}
\begin{tabular}{|l::c:r|}\hline
A&B&C\\\hdashline
AAA&BBB&CCC\\\cdashline{1-2}
\multicolumn{2}{|l:}{AB}&C\\\hdashline\hdashline
\end{tabular}
\lipsum[1-3]
\chapter{Two}
\section{Two-One}
\end{document}

相关内容