這段程式碼定義了邊框框(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