
答案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}