summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/multenum/multienum.article
blob: 75f7f9c06950c323eddb14250b6005a8a5921908 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
%TUGBoat article A Multienumerate Package

\documentclass{article}
\usepackage{multicol,multienum}
\pagestyle{headings}
\begin{document}
\title{A Multienumerate Package}
\author{Dennis Kletzing\\Stetson University} \date{\today}
\maketitle
\begin{abstract}
{\it The {\tt multienum.sty} package  allows
the user to produce an enumerated array of multiple
columns, each vertically aligned on the counter. An optional
argument provides  for consecutive numbering of the array items,
or an even-only or odd-only numbering scheme.}
\end{abstract}
Typesetting the solutions manual for a text frequently involves creating an
enumerated list involving many short answers. Typically these are set with
several items per
line, with no attempt made to vertically align the exercise numbers. The
{\tt multienum.sty} package provides an environment, {\tt multienumerate},
that produces  an enumerated array in which columns are vertically aligned
on the counter. If the user wishes, the enumeration counter can
 be changed to give a list of even-only  numbers or odd-only
 numbers.

\begin{table}[b]
\caption{An enumerate array  of solutions}
\parbox[t]{.99\hsize}{%
\hrule\hrule
\begin{multienumerate}
\mitemxxxx{Not}{Linear}{Not}{Quadratic}
\mitemxxxo{Not}{Linear}{No; if $x=3$, then $y=-2$.}
\mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
$(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
\mitemx{$(x_1,x_2,x_3,x_4)= (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
\mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
\end{multienumerate}}\hrule
\end{table}

\section*{What the package does}
Table 1 shows  a typical enumerated array. The fourth entry in
the second row is left blank since the next item is too long to
fit in space. The third row has only two entries. To get the
vertical alignment of the counter in column 3, we set row three
as  four entries, but left entry 2 and entry 4 blank thus
giving more space for the first and third entries. To produce
the enumerated array shown above, we typed the following:




\begin{verbatim}
  \begin{multienumerate}
  \mitemxxxx{Not}{Linear}{Not}{Quadratic}
  \mitemxxxo{Not}{Linear}{Not}
  \mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
    $(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
  \mitemx{$(x_1,x_2,x_3,x_4)=
    (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
    or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
  \mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
  \end{multienumerate}
\end{verbatim}
The environment {\tt multienumerate} has an optional argument
for enumerating even-only or odd-only  arrays.\footnote{The
optional arguments works only in \LaTeX2e.}

\begin{itemize}
\item \verb|\begin{multienumerate} ... \end{multienumerate}|
\item[]   produces a consecutively enumerated  array
\item \verb|\begin{multienumerate}[evenlist] ...\end{multienumerate}|
\item[]  produces an enumerated  array using only even numbers
\item \verb|\begin{multienumerate}[oddlist] ...\end{multienumerate}|
\item[]  produces an enumerated  array using only odd numbers
\end{itemize}

\section*{Using the package}
Each row of the enumerated  array is set using
one of the nine commands:

\begin{small}
\renewcommand{\arraystretch}{1.2}%1.4
\begin{tabular}{@{}lp{3in}}
\verb|\mitemx{}|&A single item in the row.\\
\verb|\mitemxx{}{}|&Two items in the row.\\
\verb|\mitemxxx{}{}{}|&Three items in the row.\\
\verb|\mitemxox{}{}|&Three items in the row with the
center item space left blank so the first item can extend
into its space.\\
\verb|\mitemxxo{}{}|&Three items in the row with the last
item left blank so the second item can extend into
 its space.\\
\verb|\mitemxxxx{}{}{}{}|&Four items in the row.\\
\verb|\mitemxoxx{}{}{}|& Four items in the row with the
second space left blank so the first item can extend into
its space.\\
\verb|\mitemxxox{}{}{}|&Four items in the row with the
third space left blank so the second item can extend into
its space.\\
\verb|\mitemxxxo{}{}{}|&Four items in the row with the
last space left blank so the third item can extend into
its space.
\end{tabular}
\end{small}

For example, \verb|\mitemxxx{a}{b}{c}| sets three items, a, b, c equally
spaced  across the row; \verb|\mitemxox{a}{c}| sets the two
items, a and c, across the row {\em as if\/} there were three items, leaving
the second entry blank so that the first entry can extend into
its space; and \verb|\mitemxxo{a}{b}| sets the two items, a and
b, {\em as if\/} there were three items, but leaves the space
for the third item blank, allowing the second entry to extend
into its space.

A convenient way to use the multienumerate
package is with a two column layout using multicols. Page 7
illustrates  a typical page from a solutions manual  set in
two columns format using multicols and multienumerate.

A disadvantage of the package is that the user must choose how
to typeset each line in the array rather than letting \TeX\
decide how to do it. This creates a lot of overhead in the
macro since separate commands are needed for each possibility.
It is not difficult to write a macro that will let
 \TeX\  decide how many items to set on each line. This
approach, while the most efficient, does not always give the
visual appearance that the user may want.


\section{How the package works}
We illustrate how the package typesets a line
containing two items. The other
situations are similar.

\noindent
\setlength{\unitlength}{1.3pt}
\begin{picture}(240,50)(0,0)


\put(0,0){\framebox(35,10)[b]{\hfill 1.}}
\put(40,0){\framebox(30,10)[b]{}}
\put(75,0){\framebox(50,10)[bl]{stuff}}

\put(0,30){\makebox(35,10)[b]{\small
\texttt{$\backslash$labelwidth}}}
\put(40,30){\makebox(30,10)[b]{\small
\texttt{$\backslash$labelsep}}}
\put(75,30){\makebox(50,10)[b]{\small
\texttt{$.5\backslash$remainxx}}}

\put(17.5,20){\vector(-1,0){17.5}}
\put(17.5,20){\vector(1,0){17.5}}

\put(55,20){\vector(-1,0){15}}
\put(55,20){\vector(1,0){15}}

\put(100,20){\vector(-1,0){25}}
\put(100,20){\vector(1,0){25}}

\put(147.5,20){\vector(-1,0){17.5}}
\put(147.5,20){\vector(1,0){17.5}}

\put(185,20){\vector(-1,0){15}}
\put(185,20){\vector(1,0){15}}

\put(230,20){\vector(-1,0){25}}
\put(230,20){\vector(1,0){25}}

\put(130,0){\framebox(35,10)[b]{\hfill 2.}}
\put(170,0){\framebox(30,10)[b]{}}
\put(205,0){\framebox(50,10)[bl]{stuff}}

\put(130,30){\makebox(35,10)[b]{\small
\texttt{$\backslash$labelwidth}}}
\put(170,30){\makebox(30,10)[b]{\small
\texttt{$\backslash$labelsep}}}
\put(205,30){\makebox(50,10)[b]{\small
\texttt{$.5\backslash$remainxx}}}
\end{picture}

\bigskip
The total width of the line is then set equal to \verb|\hsize|:
\[\underbrace{2\texttt{$\backslash$labelwidth}+
2\texttt{$\backslash$labelsep}}_{\texttt{$\backslash$usedxx}}+
\texttt{$\backslash$remainxx}=\texttt{$\backslash$hsize}\]
\[\texttt{$\backslash$remainxx}=
\texttt{$\backslash$hsize}-
\texttt{$\backslash$usedxx}\]

\bigskip
In this way the macro determines the width of each box
 when two items are typeset on the line.

\section{The macro}
Here is the package \texttt{multienum.sty}.
\begin{verbatim}
\setlength{\hsize}{\textwidth}

%First define new lengths

\newlength{\usedx}
\newlength{\remainx}
\newlength{\usedxx}
\newlength{\remainxx}
\newlength{\usedxxx}
\newlength{\remainxxx}
\newlength{\usedxxxx}
\newlength{\remainxxxx}
\newlength{\remainxox}
\newlength{\remainxoxx}

%Define new item control sequences

\newcommand{\itemx}[1]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
\parbox[t]{\remainx}{\raggedright #1}\smallskip}

\newcommand{\itemxx}[2]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{.5\remainxx}{\raggedright #1}\hfill\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.5\remainxx}{\raggedright #2}\smallskip}

\newcommand{\itemxxx}[3]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
\parbox[t]{.3333\remainxxx}{\raggedright #1}\hfill\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
\parbox[t]{0.3333\remainxxx}{\raggedright #2}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep%
\parbox[t]{0.3333\remainxxx}{\raggedright #3}\smallskip}

\newcommand{\itemxxxx}[4]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #2}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #3}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #4}\smallskip}

\newcommand{\itemxox}[2]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{\remainxox}{\raggedright #1}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.3333\remainxxx}{\raggedright #2}\smallskip}

\newcommand{\itemxxo}[2]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.3333\remainxxx}{\raggedright #1}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{\remainxox}{\raggedright #2}\smallskip}

\newcommand{\itemxoxx}[3]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{\remainxoxx}{\raggedright #1}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #2}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #3}\smallskip}

\newcommand{\itemxxox}[3]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{\remainxoxx}{\raggedright #2}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{0.25\remainxxxx}{\raggedright #3}\smallskip}

\newcommand{\itemxxxo}[3]{\parbox[t]%
{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{.25\remainxxxx}{\raggedright #1}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{.25\remainxxxx}{\raggedright #2}\hfill%
\parbox[t]{\labelwidth}{\hfill\labelenumi}\hskip\labelsep
\parbox[t]{\remainxoxx}{\raggedright #3}\smallskip}

\newcommand{\mitemx}[1]{\item[] \itemx{#1}}
\newcommand{\mitemxx}[2]{\item[] \itemxx{#1}{#2}}
\newcommand{\mitemxxx}[3]{\item[] \itemxxx{#1}{#2}{#3}}
\newcommand{\mitemxox}[2]{\item[] \itemxox{#1}{#2}}
\newcommand{\mitemxxo}[2]{\item[] \itemxxo{#1}{#2}}
\newcommand{\mitemxxxx}[4]{\item[] \itemxxxx{#1}{#2}{#3}{#4}}
\newcommand{\mitemxoxx}[3]{\item[] \itemxoxx{#1}{#2}{#3}}
\newcommand{\mitemxxox}[3]{\item[] \itemxxox{#1}{#2}{#3}}
\newcommand{\mitemxxxo}[3]{\item[] \itemxxxo{#1}{#2}{#3}}
\newcommand{\mitemxxoo}[2]{\item[] \itemxxoo{#1}{#2}}

%Create counter options

\newcommand{\oddlist}{\setcounter{enumi}{-1}
\renewcommand{\labelenumi}
{\ifodd\value{enumi}\addtocounter{enumi}{2}%
\arabic{enumi}.\else
\addtocounter{enumi}{1}\arabic{enumi}.%
\addtocounter{enumi}{-2}\fi}}

\newcommand{\evenlist}{\setcounter{enumi}{0}
\renewcommand{\labelenumi}
{\ifodd\value{enumi}\addtocounter{enumi}{1}\arabic{enumi}.%
\addtocounter{enumi}{-2}\else
\addtocounter{enumi}{2}\arabic{enumi}.\fi}}

\newcommand{\regularlist}{\setcounter{enumi}{0}
\renewcommand{\labelenumi}
{\addtocounter{enumi}{1}\arabic{enumi}.}}

\newcommand{\listtype}[1]{#1}

%Create the environment

\newenvironment{multienumerate}[1][\regularlist]{%
\listtype{#1}
\begin{trivlist}%
\setlength{\labelwidth}{18pt}
\setlength{\labelsep}{5pt}%
\setlength{\usedx}{\labelwidth}%
\addtolength{\usedx}{\labelsep}%
\setlength{\remainx}{\hsize}%
\addtolength{\remainx}{-\usedx}%
\setlength{\usedxx}{2\labelwidth}%
\addtolength{\usedxx}{2\labelsep}%
\setlength{\remainxx}{\hsize}%
\addtolength{\remainxx}{-\usedxx}%
\setlength{\usedxxx}{3\labelwidth}%
\addtolength{\usedxxx}{3\labelsep}%
\setlength{\remainxxx}{\hsize}%
\addtolength{\remainxxx}{-\usedxxx}%
\setlength{\usedxxxx}{4\labelwidth}%
\addtolength{\usedxxxx}{4\labelsep}%
\setlength{\remainxxxx}{\hsize}%
\addtolength{\remainxxxx}{-\usedxxxx}%
\setlength{\remainxox}{.666\remainxxx}%
\addtolength{\remainxox}{\labelwidth}%
\addtolength{\remainxox}{\labelsep}%
\setlength{\remainxoxx}{.5\remainxxxx}%
\addtolength{\remainxoxx}{\labelwidth}%
\addtolength{\remainxoxx}{\labelsep}%
\setlength{\itemindent}{0pt}}{\end{trivlist}}

%%End of file `multienum.sty'
\end{verbatim}
\pagebreak

\markboth{}{SAMPLE}
\subsection*{Answers to Even Exercises}
\begin{multicols}{2}
\subsection*{Chapter 1}
\subsection*{Section 1}
\begin{multienumerate}[evenlist]
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{2}{5}{$-4$}
\end{multienumerate}
\subsection*{Section 2}
\begin{multienumerate}[evenlist]
\mitemxxo{Yes}{$3x^2+x=-2$}
\mitemx{If $x=1$, the only solution is $y=3$.}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{Yes}{No}{No}
\mitemxxx{2}{5}{$-4$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\newsavebox{\diagonal}
\savebox{\diagonal}{\setlength{\unitlength}{.6pt}
\begin{picture}(70,70)(0,0)
\put(0,0){\framebox(70,70){}}
\put(35,5){\vector(0,1){60}}
\put(5,35){\vector(1,0){60}}
\put(10,10){\line(1,1){50}}
\end{picture}}
\mitemxx{\vskip0pt\usebox{\diagonal}}{\vskip0pt\usebox{\diagonal }}
\mitemx{Johnie should sell 3 red marbles, buy 2 white marbles, and keep the
rest.}
\mitemx{Sarah should buy 2 pounds of squash, 3 pounds of potatoes, and 4
pounds of fish.}
\end{multienumerate}
\subsection*{Answers to Odd Exercises} \subsection*{Chapter 2}
\subsection*{Section 1}
\begin{multienumerate}[oddlist]
\mitemxxx{Yes}{No}{No}
\mitemxxxx{3}{5}{2}{$-8$}
\mitemxxox{7}{$2x-3y=6$}{1}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxox{$x^2-3x+7=0$}{Yes}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{2}{5}{$-4$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{$x=1$}{$y=-7$}{$z=3$}
\mitemxxx{2}{5}{$-4$}
\end{multienumerate}
\end{multicols}

\end{document}

\noindent
\rule{\hsize}{2pt}
\begin{multienumerate}
\mitemxxxx{Not}{Linear}{Not}{Quadratic}
\mitemxxxo{Not}{Linear}{No; if $x=3$, then $y=-2$.}
\mitemxx{$(x_1,x_2)=(2+\frac{1}{3}t,t)$ or
$(s,3s-6)$}{$(x_1,x_2,x_3)=(2+\frac{5}{2}s-3t,s,t)$}
\mitemx{$(x_1,x_2,x_3,x_4)= (\frac{1}{4}+\frac{5}{4}s+\frac{3}{4}t-u,s,t,u)$
or $(s,t,u,\frac{1}{4}-s+\frac{5}{4}t+\frac{3}{4}u)$}
\mitemxxxx{$(2,-1,3)$}{None}{$(2,1,0,1)$}{$(0,0,0,0)$}
\end{multienumerate}
\noindent
\rule{\hsize}{1pt}