不支持似乎有点奇怪\keeppages{x-y}
?也许我没有使用正确的语法。
此代码应进行调整,以满足文档前几页标记为 i、ii、iii、iv 等的情况。
\makeatletter
\newcommand{\discardpages}[1]{% \discardpages{<csv list>}
\xdef\discard@pages{#1}% Store pages to discard
\AtBeginShipout{% At shipout, decide whether to discard page/not
\renewcommand*{\do}[1]{% How to handle each page entry in csv list
\ifnum\value{page}=##1\relax%
\AtBeginShipoutDiscard% Discard page/not
\gdef\do####1{}% Do nothing further
\fi%
}%
\expandafter\docsvlist\expandafter{\discard@pages}% Process list of pages to discard
}%
}
\newif\ifkeeppage
\newcommand{\keeppages}[1]{% \keeppages{<csv list>}
\xdef\keep@pages{#1}% Store pages to keep
\AtBeginShipout{% At shipout, decide whether to discard page/not
\keeppagefalse%
\renewcommand*{\do}[1]{% How to handle each page entry in csv list
\ifnum\value{page}=##1\relax%
\keeppagetrue% Page should be kept
\gdef\do####1{}% Do nothing further
\fi%
}%
\expandafter\docsvlist\expandafter{\keep@pages}% Process list of pages to keep
\ifkeeppage\else\AtBeginShipoutDiscard\fi% Discard page/not
}%
}
\makeatother
答案1
问“为什么”是毫无意义的。命令已经写好了。
如果您想按页面范围选择,您可以使用该pagesel
包。
仅在文档完全编译并解析所有交叉引用后才激活页面选择选项。页面范围使用绝对页码。
\documentclass{book}
\usepackage[4-7,9] %activate options after a full compilation cycle
{pagesel}
\begin{document}
\frontmatter
TITLE
\mainmatter
\ExplSyntaxOn
\int_step_inline:nn {15}{\newpage A~PAGE}
\ExplSyntaxOff
\end{document}