为什么 changebar 包会创建一个充满“spsp”的页面,如何解决这个问题?

为什么 changebar 包会创建一个充满“spsp”的页面,如何解决这个问题?

这个问题于 2014 年 2 月 25 日 17:20 提出,是关于更改栏软件包版本 2005/09/18 v3.5c。该版本有一个错误,请参阅答案中的解释和修复https://tex.stackexchange.com/a/162383. 在正式版本2018/03/09 v3.6c中该错误已经修复。

为了将条形图放入“目录”,我使用了 changebar 包,版本 2005/09/18 v3.5c,并使用 pdflatex(TeXLive 2013,更新于 2014/02/25)编译文档至少四次。(使用latexdvi 输出,不会出现此问题。)这可以正常工作,但它还会在文档的最后一页之后创建一个充满“spsp”(大概是来自小点长度)的页面(已知问题)。 使用后页阿特别格什\afterpage{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}我可以通过将包放在前面来删除该页面\end{document},但是它既没有告诉我哪里出了问题,也没有告诉我如何纠正它。

\cbend\pagebreak\cbstartMWE 稍长一些,因为发生错误需要“临界目录长度”。即使目录中有很多内容(以防止更改栏跨越分页符)也无法解决问题。增加\cb@maxpoint任何内容都无法解决问题。

\documentclass[12pt]{report}
\usepackage[c5paper]{geometry}
\usepackage[color]{changebar}
\makeatletter
\newcommand{\cbgreen}{%
\write\@auxout{\string\@writefile{toc}{\string\cbend{}}}
\write\@auxout{\string\@writefile{toc}{\string\cbcolor{green}}}
\write\@auxout{\string\@writefile{toc}{\string\cbstart}}}
\newcommand{\cbred}{%
\write\@auxout{\string\@writefile{toc}{\string\cbend{}}}
\write\@auxout{\string\@writefile{toc}{\string\cbcolor{red}}}
\write\@auxout{\string\@writefile{toc}{\string\cbstart}}}
\begin{document}
\tableofcontents
\part{w}
\write\@auxout{\string\@writefile{toc}{\string\cbcolor{red}}}
\write\@auxout{\string\@writefile{toc}{\string\cbstart}}
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\part{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsubsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\subsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\section{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\paragraph{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsection{w}
\subsection{w}
\section{w}
\part{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\subsubsection{w}
\paragraph{w}
\paragraph{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\write\@auxout{\string\@writefile{toc}{\string\newpage}}
\part{w}
\cbgreen
\chapter{w}
\section{w}
\part{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\part{w}
\cbgreen
\chapter{w}
\cbred
\chapter{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\write\@auxout{\string\@writefile{toc}{\string\newpage}}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\part{w}
\cbred
\chapter{w}
\cbgreen
\chapter{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\cbred
\chapter{w}
\section{w}
\section{w}
\cbgreen
\chapter{w}
\section{w}
\write\@auxout{\string\@writefile{toc}{\string\cbend{}}}
\makeatother
\end{document}

答案1

该问题似乎已通过序言中的以下设置得到解决:

\makeatletter
\AtEndDocument{%
\def\cb@checkPdfxy#1#2#3#4#5{%
\cb@@findpdfpoint{#1}{#2}%
\ifdim#3sp=\cb@pdfx\relax      % <<-- original has \ifnum#3=\cb@pdfx
\ifdim#4sp=\cb@pdfy\relax      % <<-- original has \ifnum#4=\cb@pdfy
\ifdim#5=\cb@pdfz\relax
\else
\cb@error
\fi
\else
\cb@error
\fi
\else
\cb@error
\fi
}}
\makeatother
\usepackage[color]{changebar}

请注意,事物的顺序必须如上。

\tracingmacros1确实,在之前添加\end{document}并检查日志时,我们会发现其中 \let\cb@pdfxy\cb@checkPdfxy\cb@checkPdfxy上面一样,只是它使用了\ifnum#3=\cb@pdfx,,\ifnum#4=\cb@pdfy但是当它稍后扩展\cb@pdfx\cb@pdfy变成某个数字后跟时sp

我选择将测试转换为,\ifdim但另一种方法可能是修改定义临时宏的代码部分\cb@pdfx\cb@pdfy避免额外的sp(在日志中可以看到sp代码添加了)。我没有从changebar 代码中读到任何其他内容,我不知道这种替代方案是否会破坏其他东西。

修补的宏在包加载之前放入,\AtEndDocument以便\let\cb@pdfxy\cb@checkPdfxy 在加载之后执行。

应该有一种方法可以使用 进行修补etoolbox,但我注意到在 的文档中,changebar\cb@checkPdfxy被定义为\gdef其他宏(可能是选项处理)内部的 ,我没有进一步调查。无论如何,有了这个,臭名昭著的 页面spsp就消失了。

答案2

我无法使用当前的 TeXLive 2013 和使用

\immediate\write\@auxout{...}

或使用

\addtocontents{toc}{\string\cbend{}}

它与dvips驱动程序和序列一起工作latex->dvips->ps2pdf,但不与pdftex驱动程序一起工作。

相关内容