試験クラスで次のページに行を続ける方法 \fillwithlines

試験クラスで次のページに行を続ける方法 \fillwithlines

私は試験クラスを使用して試験をタイプセットしています。私は通常、\fillwithlines{3in}スペースの量を固定したいので、 で回答用のスペースを残します。しかし、質問がページの最後にあり、 で必要なスペースが\fillwithlines{3in}それを超える場合、行は次のページに続きません。代わりに、質問全体が次のページに移動され、現在のページは空白になります。この動作を変更して、行を 1 つのページで開始し、次のページに続ける方法はありますか。

\documentclass{exam}
\begin{document}
\begin{questions}
\question This question should appear on page 1. It should be followed by lines which continue on page 2.
\fillwithlines{20in}
\end{questions}
\end{document}

答え1

\cleadersループに置き換えるだけで済みます。\space改行が許可されます。

\documentclass{exam}
%\usepackage{showframe}% mwe only

\makeatletter
\def\fillwithlines#1{%
  \begingroup
  \ifhmode
    \par
  \fi
  \hrule height \z@
  \nobreak
  \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
          \vrule height \linefillheight depth \z@ width \z@
          \linefill}%
  % We use \cleaders (rather than \leaders) so that a given
  % vertical space will always produce the same number of lines
  % no matter where on the page it happens to start:
  \dimen0=\ht0
  \loop\ifdim\dimen0<#1\relax
    \advance\dimen0 by \ht0
    \copy0\space
  \repeat
  \endgroup
}
\makeatother

\begin{document}
\begin{questions}
\question This question should appear on page 1. It should be followed by lines which continue on page 2.
\fillwithlines{20in}
\end{questions}
\end{document}

関連情報