我正在使用enumitem
具有以下自定义列表的包:
\newlist{answers}{enumerate}{2}
\setlist[answers,1]{label=(\alph*), ref=(\alph*)}
\setlist[answers,2]{label=(\roman*), ref=(\alph{answersi}.\roman*)}
其目的是列出评估问题的答案。我也有类似的答案。它通常用于编写嵌套问题,例如:
Here are my answers:
\begin{answers}
\item First answer
\item Second answers:
\begin{answers}[series=innerlist]
\item Answer Two-One
\item Answer Two-Two
\end{answers}
\end{answers}
Something I need to exit for
\begin{answers}[resume, start=2]
\item \begin{answers}[resume=innerlist]
\item Answer Two-Three
\item Answer Two-Four
\end{answers}
\item Answer Three
\end{answers}
我希望恢复的外部列表从 (b) 恢复,但不显示标签,这样看起来好像列表从未中断,内部列表继续正常。我以为使用\item[]
就可以了,但是,尽管这会隐藏该项目的标签,但它会继续下一个项目为 (b),而不是 (c)。
可以这样做吗?我找不到有关这种情况的任何帖子,也没有在 enumitem 手册中找到任何内容。
编辑:我忘了说我知道我可以在恢复环境中执行以下操作:
\begin{answers}
\item[] \begin{answers}[resume=innerlist]
\item Answer Two-Three
\item Answer Two-Four
\end{answers}
\setcounter{answersi}{2}
\item Answer Three
\end{answers}
这是唯一方法/首选方法吗,或者有没有办法使用环境选项?
答案1
为了正确地恢复两者,内部和外部列表,您还应该命名series
外部列表:
\documentclass{article}
\usepackage{enumitem}
\newlist{answers}{enumerate}{2}
\setlist[answers,1]{label=(\alph*), ref=(\alph*)}
\setlist[answers,2]{label=(\roman*), ref=(\alph{answersi}.\roman*)}
\begin{document}
Here are my answers:
\begin{answers}[series=outerlist]
\item First answer
\item Second answers:
\begin{answers}[series=innerlist]
\item Answer Two-One
\item Answer Two-Two
\end{answers}
\end{answers}
Something I need to exit for
\begin{answers}[resume=outerlist]
\item[]\begin{answers}[resume=innerlist]
\item Answer Two-Three
\item Answer Two-Four
\end{answers}
\item Answer Three
\end{answers}
\end{document}
在您的情况下,它甚至可以在不命名外部列表的情况下工作,仅start
一起使用resume
没有多大意义(示例扩展为没有相同的计数器值来恢复内部和外部列表):
\documentclass{article}
\usepackage{enumitem}
\newlist{answers}{enumerate}{2}
\setlist[answers,1]{label=(\alph*), ref=(\alph*)}
\setlist[answers,2]{label=(\roman*), ref=(\alph{answersi}.\roman*)}
\begin{document}
Here are my answers:
\begin{answers}
\item First answer
\item Second answers:
\begin{answers}[series=innerlist]
\item Answer Two-One
\item Answer Two-Two
\item Answer Two-Three
\item Answer Two-Four
\end{answers}
\end{answers}
Something I need to exit for
\begin{answers}[resume]
\item[]\begin{answers}[resume=innerlist]
\item Answer Two-Five
\item Answer Two-Six
\end{answers}
\item Answer Three
\end{answers}
\end{document}
但是,如果您更喜欢使用start
值,请使用正确的值。因此,如果第一个自动编号的项目应该是 c,请使用 3(因为它是字母表中的第三个字母):
\documentclass{article}
\usepackage{enumitem}
\newlist{answers}{enumerate}{2}
\setlist[answers,1]{label=(\alph*), ref=(\alph*)}
\setlist[answers,2]{label=(\roman*), ref=(\alph{answersi}.\roman*)}
\begin{document}
Here are my answers:
\begin{answers}
\item First answer
\item Second answers:
\begin{answers}[series=innerlist]
\item Answer Two-One
\item Answer Two-Two
\end{answers}
\end{answers}
Something I need to exit for
\begin{answers}[start=3]
\item[]\begin{answers}[resume=innerlist]
\item Answer Two-Three
\item Answer Two-Four
\end{answers}
\item Answer Three
\end{answers}
\end{document}
结果与第一个例子所示相同。