\fillwithlines{\stretch{1}} 仅 .6\textwidth

\fillwithlines{\stretch{1}} 仅 .6\textwidth

我正在使用考试包,\fillwithlines{\stretch{1}}但只想使用它来.6\textwidth跨页面。我尝试过使用 minipage、parbox 和 makebox,但它们都无法使用该\stretch{1}命令。

下面的代码根本不打印任何行。

\documentclass{exam}

\begin{document}
    \begin{questions}
        \question Question\newline
            \begin{minipage}[b]{.6\linewidth}
                \fillwithlines{\stretch{1}}
            \end{minipage}
    \end{questions}
\end{document}

答案1

使用以下变体\fillwithlines允许您将线条的宽度指定为可选参数(默认值= \textwidth):

\documentclass{exam}

\makeatletter
\newcommand\mlinefill[1]{\leavevmode
    \leaders\hrule height \linefillthickness\hfill%
\rule{\dimexpr\textwidth-#1\relax}{0pt}\kern\z@}

\newcommand\mfillwithlines[2][\textwidth]{%
  \begingroup
  \ifhmode
    \par
  \fi
  \hrule height \z@
  \nobreak
  \setbox0=\hbox to \hsize{\hskip \@totalleftmargin
          \vrule height \linefillheight depth \z@ width \z@
          \mlinefill{#1}}%
  % 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:
  \cleaders \copy0 \vskip #2 \hbox{}%
  \endgroup
}
\makeatother

\begin{document}
    \begin{questions}
        \question Question\newline
                \mfillwithlines[.6\textwidth]{\stretch{1}}
    \end{questions}
\end{document}

相关内容