summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-interruptlist.html
blob: b4f1b4132ececbc391cc13053cc87bdc9c30baea (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<head>
<title>UK TeX FAQ -- question label interruptlist</title>
</head><body>
<h3>Interrupting enumerated lists</h3>
<p/>It&rsquo;s often convenient to have commentary text, &lsquo;outside&rsquo; the list,
between successive entries of a list.  In the case of
<code>itemize</code> lists this is no problem, since there&rsquo;s never
anything to distinguish successive items, while in the case of
<code>description</code> lists, the item labels are under the user&rsquo;s
control so there&rsquo;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}
&lt;Commentary text&gt;
\begin{enumerate}
  \setcounter{enumi}{\value{saveenum}}
  ...
\end{enumerate}
</pre>
</blockquote><p>
<p/>This is reasonable, in small doses&hellip; Problems (apart from sheer
verbosity) are getting the level right (&ldquo;should I use counter
<code>enumi</code>, <code>enumii</code>, &hellip;&rdquo;) and remembering not to
nest the interruptions (i.e., not to have a separate list, that is
itself interrupted) in the &ldquo;commentary text&rdquo;).
<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}
&lt;Commentary text&gt;
\resume{enumerate}
  ...
\end{enumerate}
</pre>
</blockquote><p>
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&rsquo;re suspending a <a href="FAQ-enumerate.html">fancy-enumeration list</a>,
you need to 
re-supply the optional &ldquo;item label layout&rdquo; 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}
&lt;comment&gt;
\resume{enumerate}[{[\textbf{Item} i]}]
...
\end{enumerate}
</pre>
</blockquote><p>
The <i>enumitem</i> package, in its most recent
release, will also allow you to resume lists:
<blockquote>
<pre>
\begin{enumerate}
...
\end{enumerate}
&lt;comment&gt;
\begin{enumerate}[resume]
...
\end{enumerate}
</pre>
</blockquote><p>
which feels just as &ldquo;natural&rdquo; as the <i>mdwtools</i> facility,
and has the advantage of playing well with the other excellent
facilities of <i>enumitem</i>.
<p/><i>Expdlist</i> has a neat way of providing for comments, with its
<code>\</code><code>listpart</code> command.  The command&rsquo;s argument becomes a comment
between items of the list:
<blockquote>
<pre>
\begin{enumerate}
\item item 1
\item item 2
  \listpart{interpolated comment}
\item item 3
\end{enumerate}
</pre>
</blockquote><p>
This, you will realise, means it doesn&rsquo;t even have to think about
suspending or resuming the list, and of course it works equally well
in any of the list environments (thought it&rsquo;s not actually
<em>necessary</em> for any but <code>enumerate</code>).
<p/><i>Enumitem</i> also allows multi-level suspension and resumption
of lists:
<blockquote>
<pre>
\begin{enumerate}
\item outer item 1
\end{enumerate}
&lt;comment&gt;
\begin{enumerate}[resume]
\item outer item 2
% nested enumerate
\begin{enumerate}
\item inner item 1
\end{enumerate}
&lt;nested comment&gt;
% resume nested enumerate
\begin{enumerate}[resume]
\item inner item 2
\end{enumerate}
\item outer item 3
% end outer enumerate
\end{enumerate}
</pre>
</blockquote><p>
However, the &lsquo;nested comment&rsquo; interpolated in the nested enumeration
appears as if it were a second paragraph to &ldquo;outer item 2&rdquo;, which is
hardly satisfactory.
<dl>
<dt><tt><i>enumerate.sty</i></tt><dd>Distributed as part of <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools.zip">macros/latex/required/tools</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/required/tools/">browse the directory</a>)
<dt><tt><i>enumitem.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/enumitem.zip">macros/latex/contrib/enumitem</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/enumitem/">browse the directory</a>)
<dt><tt><i>expdlist.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/expdlist.zip">macros/latex/contrib/expdlist</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/expdlist/">browse the directory</a>)
<dt><tt><i>mdwlist.sty</i></tt><dd>Distributed as part of <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/mdwtools.zip">macros/latex/contrib/mdwtools</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/mdwtools/">browse the directory</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>