“\output 处于活动状态时 \vbox 未满”,调整拉伸/收缩不会使错误消失

“\output 处于活动状态时 \vbox 未满”,调整拉伸/收缩不会使错误消失

我打算使用 sidenote 包以及 David Carlisle 的实现,\marginpar基于\pdfsavedpos此处的答案:https://tex.stackexchange.com/a/52436/44160。我稍微简化了\sidenote命令,这不是完整版本。

以下代码背后的基本思想是提供 的替代实现\marginpar,它使用 marginpar 的保存位置,而不是使用常规的\c@page相关的宏(并不总是使用正确的页码)。

下面的代码会产生“活动\vbox时未满\output(不良程度 10000)”消息,我不确定问题出在哪里。

我该怎么做才能消除这个错误?

PS:下面的代码需要运行两次 LaTeX 才能显示错误。

\documentclass[twoside]{article}

\usepackage{xparse}
\makeatletter


\NewDocumentCommand \sidenote { +m }
{
  \marginpar{#1}
}
%\let\sidenote\marginpar


\newbox\@mpbox
\global\setbox\@mpbox\vbox{}
\def\savedpos#1#2#3#4{%
\begingroup
\let\@positions\relax
\expandafter\xdef\csname sp@#1-#2\endcsname{%
\expandafter\ifx\csname sp@#1-#2\endcsname\relax
\else
\csname sp@#1-#2\endcsname
\fi
  \@positions{#3}{#4}}%
\endgroup}

\def\marginpar#1{%
  \saveposition{mpar}%
  \global\setbox\@mpbox\vbox{\unvbox\@mpbox\hbox{%
  \hbox{\parbox{\marginparwidth}{\@marginparreset#1}}%
  \hbox{\parbox{\marginparwidth}{\@marginparreset#1}}%
}\break}}

\def\saveposition#1{%
\pdfsavepos\write\@auxout{%
  \noexpand\savedpos
    {#1}{\the\c@page}{\the\pdflastxpos}{\the\pdflastypos}}}

\def\@oddfoot{%
  \hss\thepage\hss\rlap{\hskip\marginparsep\mcolumn}}
\def\@evenfoot{%
  \llap{\mcolumn\hskip\marginparsep}\hss\thepage\hss\saveposition{foot}}

\def\mcolumn{%
\saveposition{foot}%
\expandafter\ifx\csname sp@foot-\the\c@page\endcsname\relax
\else
\let\@positions\origin@positions
\csname sp@foot-\the\c@page\endcsname
\smash{\raise\footskip\vbox to \textheight{\hsize\marginparwidth
\hrule\@height\z@
\let\@positions\mp@positions
\csname sp@mpar-\the\c@page\endcsname
\vskip\z@\@plus\textheight% not here
\hrule\@height\z@}}%
\fi}

\def\origin@positions#1#2{%
\@tempdima\z@
\dimen@\textheight
\advance\dimen@\headsep
\advance\dimen@ #2sp
}
\def\mp@positions#1#2{%
\setbox\tw@=\vsplit\@mpbox to \maxdimen
\setbox\tw@\vbox{%
\unvbox\tw@
\setbox\tw@\lastbox
\setbox\tw@\hbox{%
\unhbox\tw@
\ifodd\c@page
\global\setbox1\lastbox
\fi
\global\setbox1\lastbox
}}%
\@tempdimb\dimen@
\advance\@tempdimb-#2sp
\ifdim\@tempdimb<2\p@
\@tempdimb2\p@
\fi
\vskip\@tempdimb\@minus\@tempdimb% not here either apparently
\advance\dimen@-\@tempdimb
\advance\dimen@-\ht\@ne
\advance\dimen@-\dp\@ne
\hrule\@height\z@
\box\@ne
\hrule\@height\z@
}

\makeatother

% just some filler text, equations, etc.
\def\someequation{%
\begin{equation}
\left[\frac{\hat p^2}{2m}+V(r)\right]\psi(r)=E\psi(r).
\end{equation}
}
\def\elementarytext{%
One two three four, united states marine core.
}
\def\sometext{%
\elementarytext\elementarytext\elementarytext\elementarytext\par
\elementarytext\elementarytext\elementarytext\elementarytext\par
\elementarytext\elementarytext\elementarytext\elementarytext\par
}

\begin{document}

\sometext

\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext\sidenote{Here is a side note with some text.}
\someequation
\elementarytext\sidenote{Here is a side note with some text.}

\end{document}

答案1

如果这些警告(虚假的)打扰到你,只要将其关闭即可:

我简化了 MWE,删除了 xparse 定义\sidenote 并添加了设置以\vbadness消除警告。

\documentclass[twoside]{article}


\makeatletter



\newbox\@mpbox
\global\setbox\@mpbox\vbox{}
\def\savedpos#1#2#3#4{%
\begingroup
\let\@positions\relax
\expandafter\xdef\csname sp@#1-#2\endcsname{%
\expandafter\ifx\csname sp@#1-#2\endcsname\relax
\else
\csname sp@#1-#2\endcsname
\fi
  \@positions{#3}{#4}}%
\endgroup}

\long\def\marginpar#1{%
  \saveposition{mpar}%
  \global\setbox\@mpbox\vbox{\unvbox\@mpbox\hbox{%
  \hbox{\parbox{\marginparwidth}{\@marginparreset#1}}%
  \hbox{\parbox{\marginparwidth}{\@marginparreset#1}}%
}\break}}

\def\saveposition#1{%
\pdfsavepos\write\@auxout{%
  \noexpand\savedpos
    {#1}{\the\c@page}{\the\pdflastxpos}{\the\pdflastypos}}}

\def\@oddfoot{%
  \hss\thepage\hss\rlap{\hskip\marginparsep\mcolumn}}
\def\@evenfoot{%
  \llap{\mcolumn\hskip\marginparsep}\hss\thepage\hss\saveposition{foot}}

\def\mcolumn{%
\saveposition{foot}%
\expandafter\ifx\csname sp@foot-\the\c@page\endcsname\relax
\else
\let\@positions\origin@positions
\csname sp@foot-\the\c@page\endcsname
\smash{\raise\footskip\vbox to \textheight{\hsize\marginparwidth
\hrule\@height\z@
\let\@positions\mp@positions
\csname sp@mpar-\the\c@page\endcsname
\vskip\z@\@plus\textheight% not here
\hrule\@height\z@}}%
\fi}

\def\origin@positions#1#2{%
\@tempdima\z@
\dimen@\textheight
\advance\dimen@\headsep
\advance\dimen@ #2sp
}
\def\mp@positions#1#2{%
\advance\vbadness\@M
\setbox\tw@=\vsplit\@mpbox to \maxdimen
\advance\vbadness-\@M
\setbox\tw@\vbox{%
\unvbox\tw@
\setbox\tw@\lastbox
\setbox\tw@\hbox{%
\unhbox\tw@
\ifodd\c@page
\global\setbox1\lastbox
\fi
\global\setbox1\lastbox
}}%
\@tempdimb\dimen@
\advance\@tempdimb-#2sp
\ifdim\@tempdimb<2\p@
\@tempdimb2\p@
\fi
\vskip\@tempdimb\@minus\@tempdimb% not here either apparently
\advance\dimen@-\@tempdimb
\advance\dimen@-\ht\@ne
\advance\dimen@-\dp\@ne
\hrule\@height\z@
\box\@ne
\hrule\@height\z@
}

\makeatother

% just some filler text, equations, etc.
\def\someequation{%
\begin{equation}
\left[\frac{\hat p^2}{2m}+V(r)\right]\psi(r)=E\psi(r).
\end{equation}
}
\def\elementarytext{%
One two three four, united states marine core.
}
\def\sometext{%
\elementarytext\elementarytext\elementarytext\elementarytext\par
\elementarytext\elementarytext\elementarytext\elementarytext\par
\elementarytext\elementarytext\elementarytext\elementarytext\par
}

\begin{document}

\sometext

\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext
\someequation
\elementarytext\marginpar{Here is a side note with some text.}
\someequation
\elementarytext\marginpar{Here is a side note with some text.}
\end{document}

相关内容