该代码定义了边框框(border box),然后在以下部分开始:
\ifx\PageBorderTwo\empty\else
它检查 PageBorderTwo 是否已设置,如果是,则更改 PageBorder。就给出的代码而言,Jeff 的代码看起来像是在每一页都重新加载边框 PDF,因此更改 PageBorder 会在下一次需要写入边框时生效。如果 PageBorderTwo 为空,则 PageBorder 将保持原样。
如果你不使用 Jeff 版本的代码,而是坚持使用原始版本(该版本仅在框为空时,例如在文档开始时,才重新加载 PDF),我们可以利用触发器(triggers),并在想要更改边框时将框设为空(void)。
如果你想在代码的不同位置更改边框,可以这样做:
\makeatletter
\setcvhook{GEN1.1}{\def\PageBorder{path_to_border2}\setbox\b@rder\box\voidb@x}
\sethook{bookstart}{MAT}{\let\PageBorder\empty\setbox\b@rder\box\voidb@x} % No border for NT intro
\setcvhook{MAT1.1}{\def\PageBorder{path_to_border3}\setbox\b@rder\box\voidb@x}
\makeatother
所有代码均未完全测试!
(\voidb@x 只是一个普通框,但没人应该往里面放任何东西,因此它始终是空的)
The code defines the border box and then in the bit starting:
\ifx\PageBorderTwo\empty\else
It checks if PageBorderTwo is set and if so changes PageBorder. As given, Jeff’s code looks like it reloading the border PDF each page, so changing PageBorder takes effect the next time it has to write a border. If PageBorderTwo is empty, then PageBorder will stay as it was.
If you don’t use Jeff’s version of the code, but stick to the original, that only reloads the PDF when the box is empty (e.g. at the start of the document), we can make use this with triggers, and set the box to empty (void) whenever we want to change the border.
If you want to change the border at various places in the code, you could do something like this:
\makeatletter
\setcvhook{GEN1.1}{\def\PageBorder{path_to_border2}\setbox\b@rder\box\voidb@x}
\sethook{bookstart}{MAT}{\let\PageBorder\empty\setbox\b@rder\box\voidb@x} % No border for NT intro
\setcvhook{MAT1.1}{\def\PageBorder{path_to_border3}\setbox\b@rder\box\voidb@x}
\makeatother
All code is totally untested!
(\voidb@x is just a normal box, but no one should ever put anything in it, thus it’s always void)
机器翻译自 English