你好,我想在此代码中添加几行以获得如下效果:
第一项 ------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
(需填写的行)
第二项
-----------------------------------------------------------------------------------
This is the code that I found in this forum:
\usepackage{enumitem}
\usepackage{xhfill}
\newcommand{\xfill}[2][1ex]{{%
\dimen0=#2\advance\dimen0 by #1
\leaders\hrule height \dimen0 depth -#1\hfill%
}}
\newlist{mylegal}{enumerate}{1}
\newif\iffirstlegal\firstlegalfalse% We need a toggle to track whether the item is first in the list or not
\setlist[mylegal]{%
label=\arabic*.,
before*={% This saves the standard definition of \item and then redefines it to add the fill if the item is not first on the list; if it is the first item, it omits the fill but toggles the firstlegal switch so the next item will trigger it
\let\olditem\item% save the standard definition of \item in a macro, \olditem
\firstlegaltrue% set the toggle for first item in the list to true
\def\item{\iffirstlegal\olditem\firstlegalfalse\else \xfill{.5pt}\mbox{}\olditem\fi}% new, temporary defition of \item
},
after*={% This takes care of adding the fill for the final item on the list and just makes sure that \item is reset to its standard definition
\xfill{.5pt}\mbox{}% fill for final item in list
\let\item\olditem% restore standard definition of \item
}%
}
非常感谢您的帮助 !
答案1
考虑到您的意图,如果使用exam
课程的话,这很容易。
\documentclass{exam}
\begin{document}
\begin{questions}
\question
In no more than one paragraph, explain why the earth is round.
\fillwithlines{1.5in}
\question
\begin{parts}
\part
What changes to the van Allen radiation belt are needed to make
the earth into a regular icosahedron?
\fillwithlines{3in}
\part
Where should the field generator be constructed if you want one of
the vertices to be located at the Royal Observatory at Greenwich?
\fillwithlines{1in}
\end{parts}
\end{questions}
\end{document}
还有许多其他优点,例如打印答案。
要自定义线条,请阅读手册的以下部分(texdoc exam
从终端/命令提示符)