答案1
正如评论中提到的,使用minipage
环境可能是最简单的解决方案。如果您经常这样做,您可以创建minipage
该命令的一个版本。这需要一个可选的宽度参数,如果不使用,则\fillwithlines
默认为。\linewidth
\documentclass{exam}
\NewDocumentCommand{\Fillwithlines}{O{\linewidth}m}{
\par\begin{minipage}{#1}
\fillwithlines{#2}
\end{minipage}}
\begin{document}
\begin{questions}
\question What is the answer to this question?
\Fillwithlines[3in]{1in}
\question What is the answer to this question?
\Fillwithlines{1in}
\end{questions}
\end{document}
答案2
此代码将线的硬连线长度()替换为可在问题之前设置的\hsize
自定义长度( )。\linelength
\documentclass{exam}
%**************************************** added <<<<<<<<<<<<
\usepackage{xpatch}
\newlength{\linelength}
\setlength{\linelength}{\hsize}% default length
\makeatletter
\xpatchcmd{\do@fillwithlines}
{\hsize}{\linelength}{}{}
\makeatother
%****************************************
\begin{document}
\begin{questions}
\setlength{\linelength}{1.5in}% choose the line length <<<<<<<<<<<<<<<<<<<<
\question What is your name? \fillwithlines{3cm}
\setlength{\linelength}{2.5in}% choose the line length <<<<<<<<<<<<<<<<<<<<
\question What is your name? \fillwithlines{3cm}
\end{questions}
\end{document}