Debian Codegraph @

texmf-dist/doc/latex/multenum/multienum.article

raw
1 %TUGBoat article A Multienumerate Package
2
3 \documentclass{article}
4 \usepackage{multicol,multienum}
5 \pagestyle{headings}
6 \begin{document}
7 \title{A Multienumerate Package}
8 \author{Dennis Kletzing\\Stetson University} \date{\today}
9 \maketitle
10 \begin{abstract}
11 {\it The {\tt multienum.sty} package allows
12 the user to produce an enumerated array of multiple
13 columns, each vertically aligned on the counter. An optional
14 argument provides for consecutive numbering of the array items,
15 or an even-only or odd-only numbering scheme.}
16 \end{abstract}
17 Typesetting the solutions manual for a text frequently involves creating an
18 enumerated list involving many short answers. Typically these are set with
19 several items per
20 line, with no attempt made to vertically align the exercise numbers. The
21 {\tt multienum.sty} package provides an environment, {\tt multienumerate},
22 that produces an enumerated array in which columns are vertically aligned
23 on the counter. If the user wishes, the enumeration counter can
24 be changed to give a list of even-only numbers or odd-only
25 numbers.
26
27 \begin{table}[b]
28 \caption{An enumerate array of solutions}
29 \parbox[t]{.99\hsize}{%
30 \hrule\hrule
31 \begin{multienumerate}
32 \mitemxxxx{Not}{Linear}{Not}{Quadratic}
33 \mitemxxxo{Not}{Linear}{No; if $x=3$, then $y=-2$.}
34 \mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
35 $(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
36 \mitemx{$(x_1,x_2,x_3,x_4)= (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
37 or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
38 \mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
39 \end{multienumerate}}\hrule
40 \end{table}
41
42 \section*{What the package does}
43 Table 1 shows a typical enumerated array. The fourth entry in
44 the second row is left blank since the next item is too long to
45 fit in space. The third row has only two entries. To get the
46 vertical alignment of the counter in column 3, we set row three
47 as four entries, but left entry 2 and entry 4 blank thus
48 giving more space for the first and third entries. To produce
49 the enumerated array shown above, we typed the following:
50
51
52
53
54 \begin{verbatim}
55 \begin{multienumerate}
56 \mitemxxxx{Not}{Linear}{Not}{Quadratic}
57 \mitemxxxo{Not}{Linear}{Not}
58 \mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
59 $(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
60 \mitemx{$(x_1,x_2,x_3,x_4)=
61 (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
62 or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
63 \mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
64 \end{multienumerate}
65 \end{verbatim}
66 The environment {\tt multienumerate} has an optional argument
67 for enumerating even-only or odd-only arrays.\footnote{The
68 optional arguments works only in \LaTeX2e.}
69
70 \begin{itemize}
71 \item \verb|\begin{multienumerate} ... \end{multienumerate}|
72 \item[] produces a consecutively enumerated array
73 \item \verb|\begin{multienumerate}[evenlist] ...\end{multienumerate}|
74 \item[] produces an enumerated array using only even numbers
75 \item \verb|\begin{multienumerate}[oddlist] ...\end{multienumerate}|
76 \item[] produces an enumerated array using only odd numbers
77 \end{itemize}
78
79 \section*{Using the package}
80 Each row of the enumerated array is set using
81 one of the nine commands:
82
83 \begin{small}
84 \renewcommand{\arraystretch}{1.2}%1.4
85 \begin{tabular}{@{}lp{3in}}
86 \verb|\mitemx{}|&A single item in the row.\\
87 \verb|\mitemxx{}{}|&Two items in the row.\\
88 \verb|\mitemxxx{}{}{}|&Three items in the row.\\
89 \verb|\mitemxox{}{}|&Three items in the row with the
90 center item space left blank so the first item can extend
91 into its space.\\
92 \verb|\mitemxxo{}{}|&Three items in the row with the last
93 item left blank so the second item can extend into
94 its space.\\
95 \verb|\mitemxxxx{}{}{}{}|&Four items in the row.\\
96 \verb|\mitemxoxx{}{}{}|& Four items in the row with the
97 second space left blank so the first item can extend into
98 its space.\\
99 \verb|\mitemxxox{}{}{}|&Four items in the row with the
100 third space left blank so the second item can extend into
101 its space.\\
102 \verb|\mitemxxxo{}{}{}|&Four items in the row with the
103 last space left blank so the third item can extend into
104 its space.
105 \end{tabular}
106 \end{small}
107
108 For example, \verb|\mitemxxx{a}{b}{c}| sets three items, a, b, c equally
109 spaced across the row; \verb|\mitemxox{a}{c}| sets the two
110 items, a and c, across the row {\em as if\/} there were three items, leaving
111 the second entry blank so that the first entry can extend into
112 its space; and \verb|\mitemxxo{a}{b}| sets the two items, a and
113 b, {\em as if\/} there were three items, but leaves the space
114 for the third item blank, allowing the second entry to extend
115 into its space.
116
117 A convenient way to use the multienumerate
118 package is with a two column layout using multicols. Page 7
119 illustrates a typical page from a solutions manual set in
120 two columns format using multicols and multienumerate.
121
122 A disadvantage of the package is that the user must choose how
123 to typeset each line in the array rather than letting \TeX\
124 decide how to do it. This creates a lot of overhead in the
125 macro since separate commands are needed for each possibility.
126 It is not difficult to write a macro that will let
127 \TeX\ decide how many items to set on each line. This
128 approach, while the most efficient, does not always give the
129 visual appearance that the user may want.
130
131
132 \section{How the package works}
133 We illustrate how the package typesets a line
134 containing two items. The other
135 situations are similar.
136
137 \noindent
138 \setlength{\unitlength}{1.3pt}
139 \begin{picture}(240,50)(0,0)
140
141
142 \put(0,0){\framebox(35,10)[b]{\hfill 1.}}
143 \put(40,0){\framebox(30,10)[b]{}}
144 \put(75,0){\framebox(50,10)[bl]{stuff}}
145
146 \put(0,30){\makebox(35,10)[b]{\small
147 \texttt{$\backslash$labelwidth}}}
148 \put(40,30){\makebox(30,10)[b]{\small
149 \texttt{$\backslash$labelsep}}}
150 \put(75,30){\makebox(50,10)[b]{\small
151 \texttt{$.5\backslash$remainxx}}}
152
153 \put(17.5,20){\vector(-1,0){17.5}}
154 \put(17.5,20){\vector(1,0){17.5}}
155
156 \put(55,20){\vector(-1,0){15}}
157 \put(55,20){\vector(1,0){15}}
158
159 \put(100,20){\vector(-1,0){25}}
160 \put(100,20){\vector(1,0){25}}
161
162 \put(147.5,20){\vector(-1,0){17.5}}
163 \put(147.5,20){\vector(1,0){17.5}}
164
165 \put(185,20){\vector(-1,0){15}}
166 \put(185,20){\vector(1,0){15}}
167
168 \put(230,20){\vector(-1,0){25}}
169 \put(230,20){\vector(1,0){25}}
170
171 \put(130,0){\framebox(35,10)[b]{\hfill 2.}}
172 \put(170,0){\framebox(30,10)[b]{}}
173 \put(205,0){\framebox(50,10)[bl]{stuff}}
174
175 \put(130,30){\makebox(35,10)[b]{\small
176 \texttt{$\backslash$labelwidth}}}
177 \put(170,30){\makebox(30,10)[b]{\small
178 \texttt{$\backslash$labelsep}}}
179 \put(205,30){\makebox(50,10)[b]{\small
180 \texttt{$.5\backslash$remainxx}}}
181 \end{picture}
182
183 \bigskip
184 The total width of the line is then set equal to \verb|\hsize|:
185 \[\underbrace{2\texttt{$\backslash$labelwidth}+
186 2\texttt{$\backslash$labelsep}}_{\texttt{$\backslash$usedxx}}+
187 \texttt{$\backslash$remainxx}=\texttt{$\backslash$hsize}\]
188 \[\texttt{$\backslash$remainxx}=
189 \texttt{$\backslash$hsize}-
190 \texttt{$\backslash$usedxx}\]
191
192 \bigskip
193 In this way the macro determines the width of each box
194 when two items are typeset on the line.
195
196 \section{The macro}
197 Here is the package \texttt{multienum.sty}.
198 \begin{verbatim}
199 \setlength{\hsize}{\textwidth}
200
201 %First define new lengths
202
203 \newlength{\usedx}
204 \newlength{\remainx}
205 \newlength{\usedxx}
206 \newlength{\remainxx}
207 \newlength{\usedxxx}
208 \newlength{\remainxxx}
209 \newlength{\usedxxxx}
210 \newlength{\remainxxxx}
211 \newlength{\remainxox}
212 \newlength{\remainxoxx}
213
214 %Define new item control sequences
215
216 \newcommand{\itemx}[1]{\parbox[t]%
217 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
218 \parbox[t]{\remainx}{\raggedright #1}\smallskip}
219
220 \newcommand{\itemxx}[2]{\parbox[t]%
221 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
222 \parbox[t]{.5\remainxx}{\raggedright #1}\hfill\parbox[t]%
223 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
224 \parbox[t]{0.5\remainxx}{\raggedright #2}\smallskip}
225
226 \newcommand{\itemxxx}[3]{\parbox[t]%
227 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
228 \parbox[t]{.3333\remainxxx}{\raggedright #1}\hfill\parbox[t]%
229 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
230 \parbox[t]{0.3333\remainxxx}{\raggedright #2}\hfill%
231 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
232 \parbox[t]{0.3333\remainxxx}{\raggedright #3}\smallskip}
233
234 \newcommand{\itemxxxx}[4]{\parbox[t]%
235 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
236 \parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill\parbox[t]%
237 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
238 \parbox[t]{0.25\remainxxxx}{\raggedright #2}\hfill%
239 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
240 \parbox[t]{0.25\remainxxxx}{\raggedright #3}\hfill%
241 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
242 \parbox[t]{0.25\remainxxxx}{\raggedright #4}\smallskip}
243
244 \newcommand{\itemxox}[2]{\parbox[t]%
245 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
246 \parbox[t]{\remainxox}{\raggedright #1}\hfill%
247 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
248 \parbox[t]{0.3333\remainxxx}{\raggedright #2}\smallskip}
249
250 \newcommand{\itemxxo}[2]{\parbox[t]%
251 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
252 \parbox[t]{0.3333\remainxxx}{\raggedright #1}\hfill%
253 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
254 \parbox[t]{\remainxox}{\raggedright #2}\smallskip}
255
256 \newcommand{\itemxoxx}[3]{\parbox[t]%
257 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
258 \parbox[t]{\remainxoxx}{\raggedright #1}\hfill%
259 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
260 \parbox[t]{0.25\remainxxxx}{\raggedright #2}\hfill%
261 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
262 \parbox[t]{0.25\remainxxxx}{\raggedright #3}\smallskip}
263
264 \newcommand{\itemxxox}[3]{\parbox[t]%
265 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
266 \parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill%
267 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
268 \parbox[t]{\remainxoxx}{\raggedright #2}\hfill%
269 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
270 \parbox[t]{0.25\remainxxxx}{\raggedright #3}\smallskip}
271
272 \newcommand{\itemxxxo}[3]{\parbox[t]%
273 {\labelwidth}{\hfill\labelenumi}\hskip\labelsep
274 \parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill%
275 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
276 \parbox[t]{.25\remainxxxx}{\raggedright #2}\hfill%
277 \parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
278 \parbox[t]{\remainxoxx}{\raggedright #3}\smallskip}
279
280 \newcommand{\mitemx}[1]{\item[] \itemx{#1}}
281 \newcommand{\mitemxx}[2]{\item[] \itemxx{#1}{#2}}
282 \newcommand{\mitemxxx}[3]{\item[] \itemxxx{#1}{#2}{#3}}
283 \newcommand{\mitemxox}[2]{\item[] \itemxox{#1}{#2}}
284 \newcommand{\mitemxxo}[2]{\item[] \itemxxo{#1}{#2}}
285 \newcommand{\mitemxxxx}[4]{\item[] \itemxxxx{#1}{#2}{#3}{#4}}
286 \newcommand{\mitemxoxx}[3]{\item[] \itemxoxx{#1}{#2}{#3}}
287 \newcommand{\mitemxxox}[3]{\item[] \itemxxox{#1}{#2}{#3}}
288 \newcommand{\mitemxxxo}[3]{\item[] \itemxxxo{#1}{#2}{#3}}
289 \newcommand{\mitemxxoo}[2]{\item[] \itemxxoo{#1}{#2}}
290
291 %Create counter options
292
293 \newcommand{\oddlist}{\setcounter{enumi}{-1}
294 \renewcommand{\labelenumi}
295 {\ifodd\value{enumi}\addtocounter{enumi}{2}%
296 \arabic{enumi}.\else
297 \addtocounter{enumi}{1}\arabic{enumi}.%
298 \addtocounter{enumi}{-2}\fi}}
299
300 \newcommand{\evenlist}{\setcounter{enumi}{0}
301 \renewcommand{\labelenumi}
302 {\ifodd\value{enumi}\addtocounter{enumi}{1}\arabic{enumi}.%
303 \addtocounter{enumi}{-2}\else
304 \addtocounter{enumi}{2}\arabic{enumi}.\fi}}
305
306 \newcommand{\regularlist}{\setcounter{enumi}{0}
307 \renewcommand{\labelenumi}
308 {\addtocounter{enumi}{1}\arabic{enumi}.}}
309
310 \newcommand{\listtype}[1]{#1}
311
312 %Create the environment
313
314 \newenvironment{multienumerate}[1][\regularlist]{%
315 \listtype{#1}
316 \begin{trivlist}%
317 \setlength{\labelwidth}{18pt}
318 \setlength{\labelsep}{5pt}%
319 \setlength{\usedx}{\labelwidth}%
320 \addtolength{\usedx}{\labelsep}%
321 \setlength{\remainx}{\hsize}%
322 \addtolength{\remainx}{-\usedx}%
323 \setlength{\usedxx}{2\labelwidth}%
324 \addtolength{\usedxx}{2\labelsep}%
325 \setlength{\remainxx}{\hsize}%
326 \addtolength{\remainxx}{-\usedxx}%
327 \setlength{\usedxxx}{3\labelwidth}%
328 \addtolength{\usedxxx}{3\labelsep}%
329 \setlength{\remainxxx}{\hsize}%
330 \addtolength{\remainxxx}{-\usedxxx}%
331 \setlength{\usedxxxx}{4\labelwidth}%
332 \addtolength{\usedxxxx}{4\labelsep}%
333 \setlength{\remainxxxx}{\hsize}%
334 \addtolength{\remainxxxx}{-\usedxxxx}%
335 \setlength{\remainxox}{.666\remainxxx}%
336 \addtolength{\remainxox}{\labelwidth}%
337 \addtolength{\remainxox}{\labelsep}%
338 \setlength{\remainxoxx}{.5\remainxxxx}%
339 \addtolength{\remainxoxx}{\labelwidth}%
340 \addtolength{\remainxoxx}{\labelsep}%
341 \setlength{\itemindent}{0pt}}{\end{trivlist}}
342
343 %%End of file `multienum.sty'
344 \end{verbatim}
345 \pagebreak
346
347 \markboth{}{SAMPLE}
348 \subsection*{Answers to Even Exercises}
349 \begin{multicols}{2}
350 \subsection*{Chapter 1}
351 \subsection*{Section 1}
352 \begin{multienumerate}[evenlist]
353 \mitemxxx{2}{5}{$-4$}
354 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
355 \mitemxox{$x^2-3x+7=0$}{Yes}
356 \mitemxxx{2}{5}{$-4$}
357 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
358 \mitemxox{$x^2-3x+7=0$}{Yes}
359 \mitemxxx{2}{5}{$-4$}
360 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
361 \mitemxox{$x^2-3x+7=0$}{Yes}
362 \mitemxxx{2}{5}{$-4$}
363 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
364 \mitemxxx{2}{5}{$-4$}
365 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
366 \mitemxxx{2}{5}{$-4$}
367 \end{multienumerate}
368 \subsection*{Section 2}
369 \begin{multienumerate}[evenlist]
370 \mitemxxo{Yes}{$3x^2+x=-2$}
371 \mitemx{If $x=1$, the only solution is $y=3$.}
372 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
373 \mitemxxx{Yes}{No}{No}
374 \mitemxxx{2}{5}{$-4$}
375 \mitemxox{$x^2-3x+7=0$}{Yes}
376 \mitemxxx{2}{5}{$-4$}
377 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
378 \mitemxox{$x^2-3x+7=0$}{Yes}
379 \mitemxxx{2}{5}{$-4$}
380 \newsavebox{\diagonal}
381 \savebox{\diagonal}{\setlength{\unitlength}{.6pt}
382 \begin{picture}(70,70)(0,0)
383 \put(0,0){\framebox(70,70){}}
384 \put(35,5){\vector(0,1){60}}
385 \put(5,35){\vector(1,0){60}}
386 \put(10,10){\line(1,1){50}}
387 \end{picture}}
388 \mitemxx{\vskip0pt\usebox{\diagonal}}{\vskip0pt\usebox{\diagonal }}
389 \mitemx{Johnie should sell 3 red marbles, buy 2 white marbles, and keep the
390 rest.}
391 \mitemx{Sarah should buy 2 pounds of squash, 3 pounds of potatoes, and 4
392 pounds of fish.}
393 \end{multienumerate}
394 \subsection*{Answers to Odd Exercises} \subsection*{Chapter 2}
395 \subsection*{Section 1}
396 \begin{multienumerate}[oddlist]
397 \mitemxxx{Yes}{No}{No}
398 \mitemxxxx{3}{5}{2}{$-8$}
399 \mitemxxox{7}{$2x-3y=6$}{1}
400 \mitemxxx{2}{5}{$-4$}
401 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
402 \mitemxox{$x^2-3x+7=0$}{Yes}
403 \mitemxxx{2}{5}{$-4$}
404 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
405 \mitemxxx{2}{5}{$-4$}
406 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
407 \mitemxxx{$x=1$}{$y=-7$}{$z=3$}
408 \mitemxxx{2}{5}{$-4$}
409 \end{multienumerate}
410 \end{multicols}
411
412 \end{document}
413
414 \noindent
415 \rule{\hsize}{2pt}
416 \begin{multienumerate}
417 \mitemxxxx{Not}{Linear}{Not}{Quadratic}
418 \mitemxxxo{Not}{Linear}{No; if $x=3$, then $y=-2$.}
419 \mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
420 $(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
421 \mitemx{$(x_1,x_2,x_3,x_4)= (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
422 or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
423 \mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
424 \end{multienumerate}
425 \noindent
426 \rule{\hsize}{1pt}
427
428