O código define a caixa da borda e, na parte que começa com:
\ifx\PageBorderTwo\empty\else
Ele verifica se PageBorderTwo está definido e, se estiver, altera PageBorder. Como está dado, o código do Jeff parece recarregar o PDF da borda a cada página, então a alteração de PageBorder entra em vigor na próxima vez que precisar escrever uma borda. Se PageBorderTwo estiver vazio, PageBorder permanecerá como estava.
Se você não usar a versão do código do Jeff, mas se ater à original, que só recarrega o PDF quando a caixa está vazia (por exemplo, no início do documento), podemos aproveitar isso com gatilhos (triggers) e definir a caixa como vazia (void) sempre que quisermos mudar a borda.
Se você quiser mudar a borda em vários lugares no código, poderia fazer algo assim:
\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
Todo o código é totalmente não testado!
(\voidb@x é apenas uma caixa normal, mas ninguém deveria colocar nada nela, portanto, ela está sempre vazia)
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)
Tradução automática de English