1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
<head>
<title>UK TeX FAQ -- question label interruptlist</title>
</head><body>
<h3>Interrupting enumerated lists</h3>
<p>It's often convenient to have commentary text, 'outside' the list,
between successive entries of a list. In the case of
<code>itemize</code> lists this is no problem, since there's never
anything to distinguish successive items, while in the case of
<code>description</code> lists, the item labels are under the user's
control so there's no automatic issue of continuity.
<p>For <code>enumerate</code> lists, the labels are generated
automatically, and are context-sensitive, so the context (in this
case, the state of the enumeration counter) needs to be preserved.
<p>The belt-and-braces approach is to remember the state of the
enumeration in your own counter variable, and then restore it when
restarting enumerate:
<blockquote>
<pre>
\newcounter{saveenum}
...
\begin{enumerate}
...
\setcounter{saveenum}{\value{enumi}}
\end{enumerate}
<Commentary text>
\begin{enumerate}
\setcounter{enumi}{\value{saveenum}}
...
\end{enumerate}
</pre>
</blockquote>
<p>This is reasonable, in small doses... Problems (apart from sheer
verbosity) are getting the level right ("should I use counter
<code>enumi</code>, <code>enumii</code>, ...") and remembering not to
nest the interruptions (i.e., not to have a separate list, that is
itself interrupted) in the "commentary text").
<p>The <i>mdwlist</i> package defines commands <code>\</code><code>suspend</code> and
<code>\</code><code>resume</code> that simplify the process:
<blockquote>
<pre>
\begin{enumerate}
...
\suspend{enumerate}
<Commentary text>
\resume{enumerate}
...
\end{enumerate}
</pre>
</blockquote>
The package allows an optional name (as in
<code>\</code><code>suspend[id]{enumerate}</code>) to allow you to identify a
particular suspension, and hence provide a handle for manipulating
nested suspensions.
<p>If you're suspending a <a href="FAQ-enumerate.html">fancy-enumeration list</a>,
you need to
re-supply the optional "item label layout" parameters required by
the <i>enumerate</i> package when resuming the list, whether by the
belt-and-braces approach, or by the <i>mdwlist</i>
<code>\</code><code>resume{enumerate}</code> technique. The task is a little tedious
in the <i>mdwlist</i> case, since the optional argument has to be
encapsulated, whole, inside an optional argument to <code>\</code><code>resume</code>,
which requires use of extra braces:
<blockquote>
<pre>
\begin{enumerate}[\textbf{Item} i]
...
\suspend{enumerate}
<comment>
\resume{enumerate}[{[\textbf{Item} i]}]
...
\end{enumerate}
</pre>
</blockquote>
The <i>enumitem</i> package, in its most recent
release, will allow you to resume lists, at one level only:
<blockquote>
<pre>
\begin{enumerate}
...
\end{enumerate}
<comment>
\begin{enumerate}[resume]
...
\end{enumerate}
</pre>
</blockquote>
which feels just as "natural" as the <i>mdwtools</i> facility,
and has the advantage of playing well with the other excellent
facilities of <i>enumitem</i>.
<dl>
<dt><tt><i>enumerate.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.tar.gz">macros/latex/required/tools</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/required/tools.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools/">browse</a>)
<dt><tt><i>enumitem.sty</i></tt><dd><a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/enumitem.tar.gz">macros/latex/contrib/enumitem</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/enumitem.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/enumitem/">browse</a>)
<dt><tt><i>mdwlist.sty</i></tt><dd>Distributed as part of <a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/mdwtools.tar.gz">macros/latex/contrib/mdwtools</a> (<a href="ftp://cam.ctan.org/tex-archive/macros/latex/contrib/mdwtools.zip">zip</a>, <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/mdwtools/">browse</a>)
</dl>
<p><p><p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=interruptlist">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=interruptlist</a>
</body>
|