同样是在这个链接的评论里提到,
为了使得 robust cmd 达到应有的效果,必须使用这几个 \protected@
开头的命令,而 protected 宏则没有这个要求。
因为 \label@optarg
在第一次展开 \thepage
时用的是 \edef
,而不是 \protected@edef
,只有后者才能保护 \protect
宏。问题就在于此。
由于 LaTeX 内核用 begindocument
钩子 patch 了 cleveref
的几个命令,\label@optarg
恰好在其中,所以自己 patch 也必须使用这个钩子才行。可查看 latex2e-first-aid-for-external-files.pdf 这个文件了解 patch 了哪些命令。
问 cleveref宏包在重定义\thepage中含有\textbf命令时出现报错的原因