如何在LaTeX中中断/恢复列表?

20
我想要产生类似于以下的输出内容:

1列表项

2另一个列表项

对列表项1和2的评论段落。

3更多项目

4最后的项目

我确信我以前见过一种漂亮的方式来中断和恢复这样的列表(而不需要明确设置某个计数器),但我现在无法重现它。

请注意,您可以定义一些自定义命令,例如\newcommand{\savecounteri}{\setcounter{saveenumi}{\value{enumi}}}和相应的\restorecounteri,以使这些解决方案更美观。 - Cascabel
顺便说一下,这个问题在TeX上是一年后提出的:http://tex.stackexchange.com/questions/1669/resuming-a-list - Waldir Leoncio
4个回答

22

我喜欢使用enumitem来实现这种效果:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate} \item 列表项1 \item 另一个列表项 列表项1和2的评论段落。
\begin{enumerate}[resume] \item 更进一步的项目 \item 最终项目 \end{enumerate}
\end{document}

enumitem提供了一个不错的解决方案。我个人非常喜欢这个包,因为它可以高效地进行交叉引用。 - David

12

TeX FAQ列出了几种实现此目的的方法。要获取完整详细信息,请在此处阅读。

我已经成功地在我的文件中使用了mdwlist包(它是mdwtools的一部分)。例如:

\documentclass{article}
\usepackage{mdwlist}

\begin{document}

\begin{enumerate}
\item List item
\item Another list item
\suspend{enumerate}

Paragraph of comments on list items 1 and 2.

\resume{enumerate}
\item Further item
\item Final item
\end{enumerate}

\end{document}

感谢Dervin Thunk提供的FAQ链接。


1
+1 因为这是唯一回答了实际问题(如何在不显式设置某些计数器的情况下中断和恢复列表)的答案。 - las3rjock
@Dervin Thunk - 我本来想删除我的回答,因为你链接的页面已经描述了这个问题和其他可能性。如果你撤销删除,我很乐意这样做。我没有点击链接阅读 - 抱歉。 - ChrisN
顺便说一句,如果你说你没读过它,那对我来说就足够了。 - Dervin Thunk
不错... 我对这个包没有任何了解 :P - Mica
谢谢,它有效。但是当它恢复计数器时,它也会更改其样式。如果我使用(1),(2),一旦恢复,它将使用3、4而不带括号。也许我错过了什么... - DeLac
显示剩余2条评论

8
\documentclass{article}

\begin{document}

\begin{enumerate}
\item first;

\item second;
\end{enumerate}

This is a paragraph.


\begin{enumerate}
  \setcounter{enumi}{2}
\item third;

\item and so on...
\end{enumerate}
\end{document}

编辑:正如Dervin Thunk所指出的,我在这里硬编码了2。

因此,这是一个似乎可以工作的解决方案:

\documentclass{article}

\newcounter{tempcounter}

\begin{document}

\begin{enumerate}
\item first;

\item second;
  \setcounter{tempcounter}{\value{enumi}}
\end{enumerate}

This is a paragraph.


\begin{enumerate}
  \setcounter{enumi}{\value{tempcounter}}
\item third;

\item and so on...
\end{enumerate}
\end{document}

6
问题在于你硬编码了数值...如果你在第一个枚举中添加第三个项目会发生什么?你将不得不改变所有其他硬编码的值...这是我的意见。 - Dervin Thunk

0

他要求一种不需要“显式设置某些计数器”的方法。 - drrlvn
这个并没有使用明确的计数 -- 他在列表的第二项之后不必显式地从3开始。 - Mark Rushakoff
这个答案中的“示例”链接已经失效。请使用以下网址:http://www.ctex.org/documents/latex/latex2e-html/ltx-260.html#example。 - Samuel Lelièvre

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接