如何让 \include 清除双页

如何让 \include 清除双页

我写了一个scrbook( twoside),其中 I\include为每个 归档section。由于我通常只想打印单个包含文件的页面,因此我需要\cleardoublepage在每个 之前(也可能是之后)\include获得正确的页码。

我的想法是使用\apptocmd(来自包etoolbox):

\apptocmd{\include}{\cleardoublepage}{}{}

但尽管.log文件似乎表明修补已成功,但尚未生效。

[debug] tracing \apptocmd on input line 39
[debug] analyzing '\include'
[debug] ++ control sequence is defined
[debug] ++ control sequence is a macro
[debug] ++ control sequence is a macro with parameters
[debug] ++ macro can be retokenized cleanly
[debug] == retokenizing macro now

这能做到吗?

答案1

\include在我看来,不应该被修改,因为它的目的是检查嵌套\include(这是不允许的)并调用,如果测试是否定的,则调用\@include

\@include调用\clearpage两次,分别在开始和结束时。所以你似乎想要的是

\makeatletter
\patchcmd\@include{\clearpage}{\cleardoublepage}{}{}
\patchcmd\@include{\clearpage}{\cleardoublepage}{}{}
\makeatother

答案2

使用

\pretocmd{\include}{\cleardoublepage}{}{}

完成工作。

但是按照 Heiko Oberdiek 的建议(我认为更好),也可以修补\@include

\patchcmd{\@include}{\@input@ {#1.tex}\clearpage}{\@input@ {#1.tex}\cleardoublepage}{}{}

相关内容