我想在列表的某些项目之间插入一条小线,以便它看起来大致如下:
(1) This is the first line
(2) This is the second line
--------
(3) This is the last line
这是我目前所拥有的:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\arabic*)]
\item This is the first item
\item This is the second item
\\ \rule{2cm}{1pt}
\item This is the last item
\end{enumerate}
\end{document}
但是,这会导致规则被放置在其自己的行上,从而在列表中创建一个巨大的空间:
我怎样才能画出这样的线,而没有多余的空间,也不结束枚举环境?
此外,这部分不是必需的,但是是否可以使线的左侧与列表中项目标签的左侧对齐?例如:
(1) this is the first line
------------
(2) this is the last line
答案1
当我这样做时,我希望由于该行而增加一些空间,但不会像在常规高度行上那样增加空间。另外,我希望该行从列表的左侧开始。
例如:
\documentclass{article}
\usepackage{enumitem,expdlist}
\newlist{inferenum}{enumerate}{10}
\setlist[inferenum]{%
label={\arabic*.},
ref={\arabic*},
itemsep=.25\baselineskip,
parsep=0pt,
labelindent=\parindent,
leftmargin=*,
widest={99},
align=left,
before*={%
\pagebreak[3]%
\renewcommand{\listpartsep}{-.5\baselineskip}%
\renewcommand{\inferline}{%
\listpart{%
\hspace{\trythis}\rule{25mm}{0.5pt}%
}%
}%
},
}
\let\sent\item
\newlength{\trythis}
\setlength{\trythis}{\parindent}
\newcommand{\inferline}{}
\begin{document}
\begin{inferenum}
\sent This is given as one thing.
\sent This is taken to mean another.
\inferline
\sent Finally, the upshot is the result.
\end{inferenum}
\end{document}
给出
根据你的需求,你可以这样写,例如,
\documentclass{article}
\usepackage{enumitem,expdlist}
\newlist{inferenum}{enumerate}{10}
\setlist[inferenum]{%
label={\arabic*.},
ref={\arabic*},
itemsep=.25\baselineskip,
parsep=0pt,
labelindent=\parindent,
leftmargin=*,
widest={99},
align=left,
before*={%
\pagebreak[3]%
\renewcommand{\listpartsep}{-\topsep}%
\renewcommand{\inferline}{%
\listpart{%
\hspace{2\labelindent}\rule{25mm}{0.5pt}%
}%
}%
},
}
\let\sent\item
\newcommand{\inferline}{}
\begin{document}
\begin{inferenum}
\sent This is given as one thing.
\sent This is taken to mean another.
\inferline
\sent Finally, the upshot is the result.
\end{inferenum}
\end{document}
答案2
像这样?我还\sepitem
为上面带有分隔线的项目定义了一个命令:
\documentclass{article}
\usepackage{enumitem}
\newcommand\sepitem{\item\raisebox{2.8ex}[0pt]{\rlap{\rule{2cm}{0.8pt}}}}
\begin{document}
\begin{enumerate}[label=(\arabic*)]
\item This is the first item
\item This is the second item
\item\raisebox{2.8ex}[0pt]{\rlap{\rule{2cm}{1pt}}}%
This is the last but one item
\sepitem This is the last item
\end{enumerate}
\end{document}