![有没有更有效/更优雅的方法来调整线条样式?](https://linux22.com/image/356071/%E6%9C%89%E6%B2%A1%E6%9C%89%E6%9B%B4%E6%9C%89%E6%95%88%2F%E6%9B%B4%E4%BC%98%E9%9B%85%E7%9A%84%E6%96%B9%E6%B3%95%E6%9D%A5%E8%B0%83%E6%95%B4%E7%BA%BF%E6%9D%A1%E6%A0%B7%E5%BC%8F%EF%BC%9F.png)
我正在使用该类exam
,并想更改\fillin
命令,使其产生虚线而不是实线。因此,我将命令定义复制并粘贴到我的序言中,并在适当的位置替换,如下所示\dotfill
:\hrule
\documentclass{exam}
\makeatletter
\def\@fillin@relay[#1]{%
% The first argument is in \fillin@ans, the second is #1.
\leavevmode
\ifprintanswers
\rlap{\raise -\answerclearance \hbox to #1{\hrulefill}}%
\begingroup
\setbox0 \hbox{\color@begingroup
\CorrectChoice@Emphasis \fillin@ans \color@endgroup}%
\ifdim\wd0 > #1\relax
\hbox{\CorrectChoice@Emphasis \fillin@ans}%
\else
\hbox to #1{\CorrectChoice@Emphasis \hfil \fillin@ans \hfil}%
\fi
\endgroup
\else
\raise -\answerclearance \hbox to #1{\dotfill}%
\fi
}% @fillin@relay
\makeatother
\begin{document}
\begin{questions}
\question Because I was so tired I \fillin on the bed. (lay/laid)
\end{questions}
\end{document}
这可行,但我真的需要将所有这些内容都添加到序言中吗,或者有没有更好/更有效的方法来做到这一点?
答案1
你可以做类似的事情
\documentclass{exam}
\newcommand\dotfillin{{\let\hrulefill\dotfill\fillin}}
\begin{document}
\begin{questions}
\question Because I was so tired I \dotfillin\ on the bed. (lay/laid)
\end{questions}
\end{document}