是否可以\hyper@normalise
在不覆盖所有宏的情况下向命令添加钩子。我希望在宏末尾添加一个钩子,然后\hyper@n@rmalise
才能添加自定义定义来进行规范化。
这就是我想要实现的目标:
\begingroup
\endlinechar=-1 %
\catcode`\^^A=14 %
\catcode`\^^M\active
\catcode`\%\active
\catcode`\#\active
\catcode`\_\active
\catcode`\$\active
\catcode`\&\active
\gdef\hyper@normalise{^^A
\begingroup
\catcode`\^^M\active
\def^^M{ }^^A
\catcode`\%\active
\let%\@percentchar
\let\%\@percentchar
\catcode`\#\active
\def#{\hyper@hash}^^A
\def\#{\hyper@hash}^^A
\@makeother\&^^A
\edef&{\string&}^^A
\edef\&{\string&}^^A
\edef\textunderscore{\string_}^^A
\let\_\textunderscore
\catcode`\_\active
\let_\textunderscore
\let~\hyper@tilde
\let\~\hyper@tilde
\let\textasciitilde\hyper@tilde
\let\\\@backslashchar
\edef${\string$}^^A
\Hy@safe@activestrue
\csname hyper@normalise@hook\endcsname % <--HERE
\hyper@n@rmalise
}^^A
\endgroup
但我想用\patchcmd
不需要冻结\hyper@normalise
包的方式来做到这一点。在这个宏中,很多 catcode 都发生了变化,因此会出现错误:
Runaway definition?
\active \def \catcode `\
! File ended while scanning definition of \etb@resrvda.
梅威瑟:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{hyperref}
\makeatletter
\patchcmd\hyper@normalise{\hyper@n@rmalise}{\csname hyper@normalise@hook\endcsname \hyper@n@rmalise}{}{}
\show\hyper@normalise
\makeatother
\begin{document}
aa
\end{document}