Debian Codegraph @

texmf-dist/source/latex/tablists/tablists.dtx

raw
1 % \iffalse
2 %
3 % tablists.dtx - tabulated list of short items.
4 % (c) 2007, 2008 Olga Lapko ([email protected])
5 %
6 % This program is provided under the terms of the
7 % LaTeX Project Public License distributed from CTAN
8 % archives in directory macros/latex/base/lppl.txt.
9 %
10 % \fi
11 %
12 % \iffalse
13 %<*driver>
14 \ProvidesFile{tablists.dtx}
15 %</driver>
16 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
17 %<package>\ProvidesPackage{tablists}
18 %<*package>
19 [2009/08/04 v0.0e (beta) Tabulated list of short items]
20 %</package>
21 %
22 %<*batchfile>
23 \begingroup
24
25 \input docstrip.tex
26
27 \keepsilent
28 \askforoverwritefalse
29
30 \generate{\file{tablists.sty}{\from{tablists.dtx}{package}}}
31
32 \endgroup
33 %</batchfile>
34 %
35 %<*driver>
36 \documentclass{ltxdoc}
37
38 \usepackage{ifpdf}
39 \ifpdf
40 \usepackage{mathptmx,courier}
41 \usepackage[scaled=0.90]{helvet}
42 \addtolength\marginparwidth{15pt}
43 \fi
44
45 \usepackage{paralist}
46 \usepackage{makecell}
47 \usepackage{amsthm}
48 \newtheorem{theorem}{Theorem}
49 \usepackage{tablists}
50 \IfFileExists{hyperref.sty}{\usepackage{hyperref}}{}
51 \IfFileExists{listpen.sty}{\usepackage{listpen}}{}
52 \providecommand\RestoreSpaces{\bigskip}
53 \EnableCrossrefs
54 \CodelineIndex
55 \RecordChanges
56 \makeatletter
57 \@beginparpenalty10000
58 \widowpenalty10000
59 \clubpenalty10000
60 \makeatother
61 \providecommand*{\file}[1]{\texttt{#1}}
62 \providecommand*{\package}[1]{\textsf{#1}}
63 \providecommand*{\cls}[1]{\textsf{#1}}
64 \providecommand*{\env}[1]{\texttt{#1}}
65
66 \OnlyDescription
67 \begin{document}
68 \DocInput{tablists.dtx}
69 \PrintChanges
70 \end{document}
71 %</driver>
72 % \fi
73 %
74 % \CheckSum{493}
75 %
76 % \GetFileInfo{tablists.dtx}
77 %
78 % \DoNotIndex{\newcommand,\newenvironment}
79 %
80 %
81 % \title{The \textsf{tablists} package\thanks{This
82 % file has version number \fileversion,
83 % last revised \filedate.}}
84 % \author{%
85 % Olga Lapko\\
86 % {\tt [email protected]} }
87 % \date{\filedate}
88 % \maketitle
89 % \begin{abstract}
90 % This package gives variant of environment for creating of list of short
91 % items in the way of tabular alignment. That could be useful for list of
92 % exercises in math educational literature. It allows to build one-level
93 % and two-level tabulated lists.
94 % \end{abstract}
95 %
96 % \tableofcontents
97 %
98 %\newpage
99 % \section{Building Commands}
100 %
101 % \DescribeMacro{tabenum}
102 % \DescribeMacro{\tabenumitem}
103 % \DescribeMacro{\item}
104 % The \env{tabenum} environment prints short items aligned in columns.
105 %
106 % Each item starts with |\tabenumitem| command.
107 % First example of \env{tabenum} list---please note that you may set optional
108 % argument in the same way as in modified environments from \package{enumerate}
109 % or \package{paralist} packages:
110 %\par\begin{small}%
111 %\begin{verbatim}
112 %\begin{tabenum}[\bfseries1)]%
113 %\tabenumitem
114 %$z=\displaystyle\frac xy$;
115 %\tabenumitem
116 %$2^x=9;$\cr
117 %
118 %\tabenumitem
119 %$3^{2x+3}=16 $;
120 %\tabenumitem
121 %$z=2x^2+4y^2$;\par
122 %\tabenumitem
123 %$u=\sqrt{x^2+y^2+z^2}$;
124 %\tabenumitem
125 %$v=gt+\displaystyle\frac{g}{4}t$;\\[1ex]
126 %\tabenumitem
127 %$u=2^{5x-3y+z}$;
128 %\tabenumitem
129 %$w=(v+7)^2+(u-3)^2$;
130 %
131 %
132 %\tabenumitem
133 %$5^x=\displaystyle\frac{4}{3} ;$
134 %\tabenumitem
135 %$z=(x+1)^2+y^2$;\\*
136 %\tabenumitem
137 %$2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$
138 %\tabenumitem
139 %$t=5u^2+8v^2$;
140 %\end{tabenum}
141 %\end{verbatim}
142 %\end{small}
143 % \begin{tabenum}[\bfseries1)]%
144 % \tabenumitem
145 % $z=\displaystyle\frac xy$;
146 % \tabenumitem
147 % $2^x=9;$\cr
148 %
149 % \tabenumitem
150 % $3^{2x+3}=4 $;
151 % \tabenumitem
152 % $z=2x^2+4y^2$;\par
153 % \tabenumitem
154 % $u=\sqrt{x^2+y^2+z^2}$;
155 % \tabenumitem
156 % $v=gt+\displaystyle\frac{g}{4}t$;\\[1ex]
157 % \tabenumitem
158 % $u=2^{5x-3y+z}$;
159 % \tabenumitem
160 % $w=(v+7)^2+(u-3)^2$;
161 %
162 %
163 % \tabenumitem
164 % $5^x=\displaystyle\frac{4}{3} ;$
165 % \tabenumitem
166 % $z=(x+1)^2+y^2$;\\*
167 % \tabenumitem
168 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$
169 % \tabenumitem
170 % $t=5u^2+8v^2$;
171 % \end{tabenum}
172 %
173 % You may see that empty line (or |\par| command), |\\| command and |\cr|
174 % do the same: start a new row. The |\\| macro works like in array environment
175 % and allows optional argument with vertical correction.
176 % (Also the |\\*| command suppresses breaking between pages, see next example.)
177 %
178 % Please note that two or more |\par|'s
179 % |\cr|'s or |\\|'s (and also any combination of these three commands)
180 % create additional empty lines.
181 %
182 % You may use the |\item|
183 % macro instead of |\tabenumitem| in this \env{tabenum} environments (see next examples).
184 %
185 % \DescribeMacro{\notabenumitem}
186 % \DescribeMacro{\noitem}
187 % \DescribeMacro{\skipitem}
188 % On the next step you can wish to do the list like before more compact. The
189 % |\multicolumn| does not work here correctly\footnote{
190 % Also the plain \TeX's commands like \cs{omit} and \cs{span}/\cs{multispan} commands,
191 % I think, need too complex code.}. At first you may use plain \TeX's
192 % command |\hidewidth| to hide width of widest column entry; then you may use
193 % other variant of |\tabenumitem|(|\item|) command---|\notabenumitem|(|\noitem|)---%^^A
194 % this command increases list entry, but does not create a new column;
195 % third command |\skipitem| allows you to skip
196 % one \env{tabenum} column\footnote{The \env{tabenum} column includes two columns:
197 % it works like \texttt{rl} columns in \env{tabular} environment. Thus, \cs{skipitem}
198 % equals to \texttt{\&\&} combination.}.
199 % Next example show usage of these three commands:
200 %\par\begin{small}%
201 %\begin{verbatim}
202 %\begin{tabenum}[\bfseries1)]%
203 %\item
204 %$z=\displaystyle\frac xy$;
205 %\noitem
206 %$2^x=9;$
207 %\item
208 %$3^{2x+3}=4 $.
209 %\item
210 %$z=2x^2+4y^2$;\nopagebreak
211 %
212 %\item
213 %$u=\sqrt{x^2+y^2+z^2}$;
214 %\item
215 %$v=gt+\displaystyle\frac{g}{4}t$,
216 %\item
217 %$u=2^{5x-3y+z}$.\cr
218 %\item
219 %$w=(v+7)^2+(u-3)^2$;
220 %\item
221 %$5^x=\displaystyle\frac{4}{3} ;$
222 %\item
223 %$z=(x+1)^2+y^2$;\\*
224 %\item
225 %$2+5+8+ \ldots +(3n+2)=155$,
226 % $n\in \mathrm{N};$\hidewidth\skipitem
227 %\item
228 %$t=5u^2+8v^2$;
229 %\end{tabenum}
230 %\end{verbatim}
231 %\end{small}%
232 % \begin{tabenum}[\bfseries1)]%
233 % \item\label{tabenum:I:1}
234 % $z=\displaystyle\frac xy$;
235 % \noitem\label{tabenum:I:2}
236 % $2^x=9;$
237 % \item
238 % $3^{2x+3}=4 $.
239 % \item
240 % $z=2x^2+4y^2$;\nopagebreak
241 %
242 % \item
243 % $u=\sqrt{x^2+y^2+z^2}$;
244 % \item
245 % $v=gt+\displaystyle\frac{g}{4}t$,
246 % \item
247 % $u=2^{5x-3y+z}$.\cr
248 % \item
249 % $w=(v+7)^2+(u-3)^2$;
250 % \item
251 % $5^x=\displaystyle\frac{4}{3} ;$
252 % \item
253 % $z=(x+1)^2+y^2$;\\*
254 % \item\label{tabenum:I:11}
255 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\skipitem
256 % \item
257 % $t=5u^2+8v^2$;
258 % \end{tabenum}
259 % The items \ref{tabenum:I:1} and \ref{tabenum:I:2} were joined in one column: the item \ref{tabenum:I:2}
260 % used |\noitem| (|\notabenumitem|) command. The item \ref{tabenum:I:11} occupies two columns,
261 % so it uses the |\hidewidth| (hides item width) and |\skipitem| (skips column of next item) commands.
262 %
263 %
264 % \subsection{Spacing}
265 %
266 % Vertical spaces around tabulated list are equal to the list ones |\topsep+\partopsep|.
267 %
268 % Space between rows depends on the |\jot| value, like in \package{amsmath} environments
269 % like \env{align}, \package{gather} etc.
270 %
271 % \DescribeMacro{\tabenumsep}
272 % The horizontal spacing between items of list. It defined like:
273 % \begin{quote}
274 % |\renewcommand\tabenumsep{\hskip1em}|
275 % \end{quote}
276 % The |\labelsep| parameter is used after item number.
277 %
278 % \DescribeMacro{\tabenumindent}
279 % The |\tabenumindent| command sets left margin of \env{tabenum} environment.
280 % It can be defined like horizontal space/skip or text,
281 % for example:
282 % \begin{quote}
283 % |\renewcommand\tabenumindent{\hskip\parindent}|
284 % \end{quote}
285 % or
286 % \begin{quote}
287 % |\renewcommand\tabenumindent{Word }|
288 % \end{quote}
289 % That could be useful also
290 % inside, e.g., a proper list environments like \env{enumerate} or \env{itemise}
291 % for corrections of left margins.
292 %
293 % \subsection{The \env{tabenum} environment inside a proper list}
294 %
295 % The version 0.0e of \package{tablists} package enlarges left margin
296 % of \env{tabenum}, when environment appears inside proper list,
297 % by the value of left margin of this list. Sometimes left edges
298 % of \env{tabenum} labels and list labels of the same level are not aligned
299 % correctly (it happens when |\labelwidth| value is not equal to the natural
300 % width of labels). In these cases you may define the correction skip
301 % with the |\tabenumindent| command.
302 %
303 % Also the version 0.0e loads labels of empty items of upper/outer list
304 % at the left side of the first item of \env{tabenum} automatically. It follows
305 % mechanism similar to building of empty items in list environment.
306 % (Empty items of \LaTeX\ list are consecutively stored to special box register
307 % and printed out at the beginning when the list text appears;
308 % the same happens at the beginning of \env{tabenum} environment:
309 % this box, if not empty, is printed at the left of first \env{tabenum} item.)
310 %\par\begin{small}%
311 %\begin{verbatim}
312 %\begin{enumerate}[\bfseries1)]%
313 %\item
314 %\begin{tabenum}[a)]%
315 %...
316 %\end{verbatim}%
317 %\end{small}%
318 % \begin{enumerate}[\bfseries1)]%
319 % \item
320 % \begin{tabenum}[a)]%
321 % \item
322 % {$z=\displaystyle\frac xy$};
323 % \noitem
324 % {$2^x=9;$}
325 % \item
326 % {$3^{2x+3}=4 $}.
327 % \item
328 % {$z=2x^2+4y^2$};\nopagebreak
329 %
330 % \item
331 % $u=\sqrt{x^2+y^2+z^2}$;
332 % \item
333 % $v=gt+\displaystyle\frac{g}{4}t$,
334 % \item
335 % $u=2^{5x-3y+z}$.\\
336 % \item
337 % $w=(v+7)^2+(u-3)^2$;
338 % \item
339 % $5^x=\displaystyle\frac{4}{3} ;$
340 % \item
341 % $z=(x+1)^2+y^2$;\cr
342 % \item
343 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\skipitem
344 % \item
345 % $t=5u^2+8v^2$.%
346 % \end{tabenum}%
347 % \end{enumerate}%
348 %\par\kern-\baselineskip
349 % \emph{Please note} that for the case of \env{tabenum} environment inside list,
350 % there is not compatibility between version 0.0e and earlier
351 % versions---left margin of \env{tabenum} is changed (mechanism
352 % of placing empty list items on one baseline using compensating vertical
353 % spaces could work but its calculation was changed, see also next paragraph).\smallskip
354 %
355 % \begin{small}%
356 % \DescribeMacro{\liststrut}
357 % In versions until 0.0d there was offered the |\liststrut| command in the
358 % cases when needed to put empty list item on the same line with first item of
359 % \env{tabenum}. The command raises first line of next text block at the baseline of
360 % previous. (Without any option it puts negative
361 % baselineskip. If there is a high element (any math sentence) in the first
362 % line of next text, it must be written in option without |$|'s,
363 % the height of this argument is used for compensating skips argument.)
364 % Since this command must take into account various vertical skips, which
365 % appear at the start of new item and also height of printing text,
366 % the adjusting of baselines does not always work correctly.\par
367 % \end{small}%
368 % \RestoreSpaces
369 % \subsection{The \env{subtabenum} environment: second level, variant I}
370 %
371 % \DescribeMacro{subtabenum}
372 % The second level of equations/exersizes list \env{subtabenum} based on \env{tabular}
373 % environment.
374 %
375 %\begin{small}%
376 %\begin{verbatim}
377 %\begin{tabenum}[\bfseries 1)]%
378 %\item
379 %\begin{subtabenum}[a)]%
380 %\item
381 %$z=\displaystyle\frac xy$;
382 %\noitem
383 %$2^x=9;$
384 %\item
385 %$3^{2x+3}=4 $.
386 %\item
387 %$z=2x^2+4y^2$;
388 %\end{subtabenum}
389 %
390 %\item
391 %\begin{subtabenum}[a)]%
392 %\item
393 %$u=\sqrt{x^2+y^2+z^2}$;
394 %\item
395 %...
396 %\end{subtabenum}
397 %\end{tabenum}
398 %\end{verbatim}%
399 %\end{small}%
400 % \begin{tabenum}[\bfseries 1)]%
401 % \item
402 % \begin{subtabenum}[a)]%
403 % \item
404 % $z=\displaystyle\frac xy$;
405 % \noitem
406 % $2^x=9;$
407 % \item
408 % $3^{2x+3}=4 $.
409 % \item
410 % $z=2x^2+4y^2$;
411 % \end{subtabenum}\nopagebreak
412 %
413 % \item
414 % \begin{subtabenum}[a)]
415 % \item
416 % $u=\sqrt{x^2+y^2+z^2}$;
417 % \item
418 % $v=gt+\gape[b]{\displaystyle\frac{g}{4}}t$,
419 % \item
420 % $u=2^{5x-3y+z}$.\\
421 % \item
422 % $w=(v+7)^2+(u-3)^2$;
423 % \item
424 % $5^x=\gape[b]{\displaystyle\frac{4}{3}} ;$
425 % \item
426 % $z=(x+1)^2+y^2$;\\
427 % \item
428 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\strut\skipitem
429 % \item
430 % $t=5u^2+8v^2$;
431 % \end{subtabenum}
432 % \end{tabenum}
433 % Please note that |\hidewidth| skip is followed by the |\strut| command inside
434 % \env{subtabenum} environment:
435 % the skips at the ``edges'' of \env{tabular} columns or before |\\| command doesn't work.
436 %
437 % \subsection{The \cs{subtabenumitem}/\cs{subitem} macros: second level, variant II}
438 %
439 % The previous example shows that columns were destroyed from one
440 % \env{subtabenum} environment to another. Also the rows of sublist cannot break between pages.
441 %
442 % \DescribeMacro{\subtabenumitem}
443 % \DescribeMacro{\subitem}
444 % There is another variant for two-level tabulated list. If you use second option
445 % in \env{tabenum} environment, you may use |\subtabenumitem|/|\subitem| commands
446 % for the second level\footnote{If there are not second optional argument, these commands
447 % work like \cs{tabenumitem}/\cs{item}.}.
448 %
449 % If you put |\subtabenumitem| (|\subitem|) after |\tabenumitem| (|\item|), you get extra space between
450 % two numbers, created by |\tabenumsep| skip. The |\negtabenumsep| command
451 % cancels this skip: the version 0.0c included this command inside the |\tabenumitem| definition.
452 %\par\begin{small}\openup-1pt\enlargethispage{2\baselineskip}
453 %\begin{verbatim}
454 %\def\tabenumsep{\qquad}
455 %\begin{tabenum}[\bfseries 1)][a)]%
456 %\item
457 %\subitem
458 %$z=\displaystyle\frac xy$;
459 %\nosubitem
460 %$2^x=9;$
461 %\subitem
462 %$3^{2x+3}=4 $.
463 %\subitem
464 %$z=2x^2+4y^2$;\\
465 %\startnumber{4}
466 %\item
467 %\subitem
468 %$u=\sqrt{x^2+y^2+z^2}$;
469 %\subitem
470 %$v=gt+\displaystyle\frac{g}{4}t$,
471 %\subitem
472 %$u=2^{5x-3y+z}$.\\
473 %\startsubnumber{7}\subtabrow
474 %\subitem
475 %$w=(v+7)^2+(u-3)^2$;
476 %\subitem
477 %$5^x=\displaystyle\frac{4}{3} ;$
478 %\subitem
479 %$z=(x+1)^2+y^2$;\\
480 %\subtabrow
481 %\subitem
482 %$2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\skipitem
483 %\subitem
484 %$t=5u^2+8v^2$;
485 %\end{tabenum}
486 %\end{verbatim}%
487 %\end{small}
488 % \begin{tabenum}[\bfseries 1)][a)]%
489 % \item
490 % \subitem
491 % $z=\displaystyle\frac xy$;
492 % \nosubitem
493 % $2^x=9;$
494 % \subitem
495 % $3^{2x+3}=4 $.
496 % \subitem
497 % $z=2x^2+4y^2$;\\
498 % \startnumber{4}\relax
499 % \item
500 % \subitem
501 % $u=\sqrt{x^2+y^2+z^2}$;
502 % \subitem
503 % $v=gt+\displaystyle\frac{g}{4}t$,
504 % \subitem
505 % $u=2^{5x-3y+z}$.\\
506 %\startsubnumber{7}\subtabrow
507 % \subitem
508 % $w=(v+7)^2+(u-3)^2$;
509 % \subitem
510 % $5^x=\displaystyle\frac{4}{3} ;$
511 % \subitem
512 % $z=(x+1)^2+y^2$;\\
513 %\subtabrow
514 % \subitem
515 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\skipitem
516 % \subitem
517 % $t=5u^2+8v^2$;
518 % \end{tabenum}
519 % There were used two commands |\startnumber| and |\startsubnumber| which set
520 % next start numbers for items of each of two levels\footnote{The \cs{startnumber}
521 % command can be used inside any list
522 % environment.}. The |\startnumber|
523 % allows you to divide \env{tabenum} environment and restart with necessary counter.
524 % You may still use the traditional |\setcounter{enum..}{..}| combination,
525 % if you know the level of your list and \env{tabenum}/\allowbreak\env{subtabenum} environments.
526 % For start of the new row from subitem, you need to use~\nobreak\quad1)\nobreak\enskip
527 % the |\skipitem| command to skip
528 % column, occupied by the ``parent'' label (|\tabenumitem|) and~\nobreak\quad2)\nobreak\enskip
529 % the |\negtabenumsep| command to undo column separation.
530 % These two commands abbreviated by |\subtabrow| command.
531 %
532 % \subsection{Placing the QED sign at the end of \env{tabenum} environment}
533 %
534 % When the \env{tabenum} environment is used inside \env{proof} environment (the
535 % \texttt{amsthm} package),
536 % the better way is to put QED at the end of last \env{tabenum} line. You may use
537 % the |\tabqedhere| command:
538 %
539 % \begin{theorem}%
540 % You may put the QED sign inside the \env{tabenum} environment.
541 % \end{theorem}%
542 % \begin{proof}%
543 % Let's put our favorite \env{tabenum} environment inside the \env{proof} one,
544 % and at the end of it write the |\tabqedhere| (or |\qedhere|) command:
545 %\begin{verbatim}
546 %\begin{theorem}
547 % You may put the QED sign inside the \env{tabenum} environment.
548 %\end{theorem}
549 %\begin{proof}
550 % Let's put...
551 %\begin{tabenum}[\bfseries 1)][a)]%
552 %...
553 %\subitem
554 %$t=5u^2+8v^2$;\qedhere
555 %\end{tabenum}
556 %\end{proof}
557 %\end{verbatim}%
558 % \begin{tabenum}[\bfseries 1)][a)]%
559 % \item
560 % \subitem
561 % $z=\displaystyle\frac xy$;
562 % \nosubitem
563 % $2^x=9;$
564 % \subitem
565 % $3^{2x+3}=4 $.
566 % \subitem
567 % $z=2x^2+4y^2$;\\
568 % \startnumber{4}\relax
569 % \item
570 % \subitem
571 % $u=\sqrt{x^2+y^2+z^2}$;
572 % \subitem
573 % $v=gt+\displaystyle\frac{g}{4}t$,
574 % \subitem
575 % $u=2^{5x-3y+z}$.\\ \subtabrow
576 % \subitem
577 % $w=(v+7)^2+(u-3)^2$;
578 % \subitem
579 % $5^x=\displaystyle\frac{4}{3} ;$
580 % \subitem
581 % $z=(x+1)^2+y^2$;\\ \subtabrow
582 % \subitem
583 % $2+5+8+ \ldots +(3n+2)=155$, $n\in \mathrm{N};$\hidewidth\skipitem
584 % \subitem
585 % $t=5u^2+8v^2$;\qedhere
586 % \end{tabenum}
587 % \end{proof}%
588 %
589 % \subsection{Restoring of \cs{item} as command from list environments}
590 %
591 % \DescribeMacro{\restorelistitem}
592 % For the cases when standard lists appear inside \env{tablist}, you may
593 % restore original |\item| meaning.
594 %
595 % \StopEventually{}\clearpage
596 %
597 % \section{Code of package}
598 %
599 % First goes request of \package{makecell} package.
600 % \begin{macrocode}
601 \RequirePackage{makecell}
602 \@ifpackagelater{makecell}{2007/05/24 V0.1d}{}{\PackageError
603 {tablists}{For a successful cooperation we need at least\MessageBreak
604 version `2007/05/24 V0.1d' of package makecell,\MessageBreak
605 but only version\MessageBreak
606 `\csname ver@makecell.\@pkgextension\endcsname'\MessageBreak
607 is available}\@eha\endinput}
608 % \end{macrocode}
609 %
610 % The horizontal separation space between items/columns.
611 % \begin{macrocode}
612 \newcommand\tabenumsep{\hskip1em}
613 \newcommand\negtabenumsep{%
614 \settowidth\@tempdima{\tabenumsep}\hspace*{-\@tempdima}}
615 % \end{macrocode}
616 %
617 % \begin{macro}{\tabenumitem}
618 % \begin{macro}{\subtabenumitem}
619 % Definition of aligned items of `tabular'ed list
620 % \begin{macrocode}
621 \newcommand\tabenumitem{\ifvoid\@labels\else\llap{\box\@labels\hspace{-\@totalleftmargin}}\fi
622 &\@ifnextchar[%
623 {\TeXr@@tabenumitem{&}}%
624 {\TeXr@tabenumitem{&}{\@enumctr}\setcounter{\@subenumctr}\z@}}
625 % \end{macrocode}
626 % The macro for second level of tabulated items.
627 % \begin{macrocode}
628 \newcommand\subtabenumitem{\ifnum\value{\@subenumctr}=\z@\negtabenumsep
629 \let\negtabenumsep\relax\fi&
630 \@ifnextchar[%]
631 {\TeXr@@tabenumitem{&}}%
632 {\TeXr@tabenumitem{&}{\@subenumctr}}}
633 % \end{macrocode}
634 % The macros for list and optional numeration. For a successful usage of |\label|--|\ref| mechanism
635 % the |\refstepcounter| contains were divided in two parts: the |\stepcounter| command was placed in the
636 % first column, before printing of label, on the second column was placed mechanism of creation
637 % labels.
638 % \changes{0.0b}{2007/09/07}{The \cmd{\refstepcounter} command divided into two parts to allow
639 % labels for tabular items.}
640 % \begin{macrocode}
641 \newcommand\TeXr@tabenumitem[2]{%
642 \stepcounter{#2}{\@nameuse{label#2}}#1
643 \protected@edef
644 \@currentlabel{\csname p@#2\endcsname\csname the#2\endcsname}}
645 \@ifdefinable\TeXr@@tabenumitem{}
646 \def\TeXr@@tabenumitem#1[#2]{{#2}#1}
647 % \end{macrocode}
648 % \end{macro}%
649 % \end{macro}%
650 %
651 % \begin{macro}{\notabenumitem}
652 % \begin{macro}{\nosubtabenumitem}
653 % Definition of not aligned items with emulation of spaces around.
654 % The starred form of |\notabenumitem| skips space before number.
655 % \begin{macrocode}
656 \newcommand\notabenumitem{\@ifstar
657 {\TeXr@notabenumitem{\@enumctr}}%
658 {\tabenumsep\TeXr@notabenumitem{\@enumctr}}}
659 % \end{macrocode}
660 % The macro for second level of tabulated items.
661 % \begin{macrocode}
662 \newcommand\nosubtabenumitem{\@ifstar
663 {\TeXr@notabenumitem{\@subenumctr}}%
664 {\tabenumsep\TeXr@notabenumitem{\@subenumctr}}}
665 \newcommand\TeXr@notabenumitem[1]{\@ifnextchar[%]
666 {\TeXr@@tabenumitem{\hskip\labelsep}}%
667 {\TeXr@tabenumitem{\hskip\labelsep}{#1}}}
668 % \end{macrocode}
669 % \end{macro}%
670 % \end{macro}%
671 %
672 % \begin{macro}{\skipitem}
673 % Command allows to skip column of items in tabulated list.
674 % One item column occupies two tabular ones and needs |&&| for skipping
675 % \begin{macrocode}
676 \newcommand\skipitem[1][1]{\count@=#1\multiply\count@2\advance\count@\@ne
677 \eline{\count@}}
678 % \end{macrocode}
679 % \end{macro}%
680 %
681 % \begin{macro}{\subtabrow}
682 % Command allows to skip column of items in tabulated list.
683 % One item column occupies two tabular ones and needs |&&| for skipping
684 % \begin{macrocode}
685 \newcommand\subtabrow{\skipitem\negtabenumsep}
686 % \end{macrocode}
687 % \end{macro}%
688 %
689 % \begin{macro}{\tabenumindent}
690 % If this command empty there is no any indentation. To set necessary indentation
691 % you may define this command as any text or horizontal skip.
692 % \begin{macrocode}
693 \newcommand\tabenumindent{}
694 % \end{macrocode}
695 % \end{macro}%
696 %
697 % \begin{environment}{tabenum}
698 % \begin{environment}{rtabenum}
699 % Start of definition of tabulated lists themselves---\env{tabenum}
700 % and \env{rtabenum}.
701 % They allow usage of optional argument in the same way as in
702 % \env{enumerate} environment from \package{paralist} package.
703 % The second definition, \env{rtabenum}, replaces |\Alph|/|\alph|
704 % numeration for \texttt{A}/texttt{a} entries by Russian
705 % |\Asbuk|/|\asbuk| numeration.
706 % \begin{macrocode}
707 \newenvironment{rtabenum}{\let\Alph\Asbuk\let\alph\asbuk
708 \tabenum}{\endtabenum}
709 % \end{macrocode}
710 %
711 % These environments use mechanism of optional argument from |\@enumlabel@|
712 % command.
713 % \begin{macrocode}
714 \newcommand\tabenum{\@ifnextchar[{\TeXr@tabenum@}{\TeXr@tabenum@[]}}
715 \@ifdefinable\TeXr@tabenum@{}
716 \def\TeXr@tabenum@[#1]{\@ifnextchar[%]
717 {\TeXr@tabenum@@[#1]}{\TeXr@tabenum@@[#1][]}}
718 % \end{macrocode}
719 %
720 % These environments allow two options for item numeration and subitem numeration.
721 % \begin{macrocode}
722 \@ifdefinable\TeXr@tabenum@@{}
723 \long\def\TeXr@tabenum@@[#1][#2]{\par
724 \addpenalty\@beginparpenalty
725 % \end{macrocode}
726 % Vertical spaces around \env{tabenum} similar to spaces in list environments.
727 % The space above reduced by |\jot| to make it equal to the space below.
728 % \begin{macrocode}
729 \@topsepadd\topsep\advance\@topsepadd\partopsep
730 \advance\@topsepadd-\jot
731 \ifdim\@topsepadd<\z@\@topsepadd=\z@\fi
732 \if@nobreak\vspace{-\jot}\else\addvspace\@topsepadd\fi
733 % \end{macrocode}
734 % Interline spacing enlarged by |\jot| as in \package{amsmath}'s environments like
735 % \env{align} etc.
736 % \begin{macrocode}
737 \openup\jot
738 % \end{macrocode}
739 % Check for list depth and settings for first level.
740 % If it exceeded, the error message pops out.
741 % \begin{macrocode}
742 \ifnum\@enumdepth>\thr@@
743 \@toodeep
744 \else
745 \advance\@enumdepth\@ne
746 \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
747 \setcounter{\@enumctr}\z@
748 \let\item\tabenumitem\let\noitem\notabenumitem
749 % \end{macrocode}
750 % Check for list depth and settings for second level.
751 % If it exceeded, one level used.
752 % \begin{macrocode}
753 \ifnum\@enumdepth>\thr@@
754 \PackageWarning{tablists}{tablist has one level}{}%
755 \let\subitem\tabenumitem\let\nosubitem\notabenumitem
756 \else
757 \let\subitem\subtabenumitem\let\nosubitem\nosubtabenumitem
758 \advance\@enumdepth\@ne
759 \edef\@subenumctr{enum\romannumeral\the\@enumdepth}%
760 \setcounter{\@subenumctr}\z@
761 \fi
762 \fi
763 % \end{macrocode}
764 % Checks for first option. If option is absent used default enumerating.
765 % \begin{macrocode}
766 \def\tempa{#1}\ifx\tempa\empty\else
767 \TeXr@enumlabel@{#1}{\@enumctr}\fi
768 % \end{macrocode}
769 % Checks for second option. If option is absent used default enumerating.
770 % \begin{macrocode}
771 \def\tempa{#2}\ifx\tempa\empty\else
772 \TeXr@enumlabel@{#2}{\@subenumctr}\fi
773 \@TeXr@tabenum
774 }
775 % \end{macrocode}
776 % There building macro for item/subitem labels.
777 % \begin{macrocode}
778 \newcommand\TeXr@enumlabel@[2]{%
779 \@tempcnta0
780 \TeXr@lab{}\def\TeXr@label{\TeXr@label@{#2}}%
781 \expandafter\TeXr@loop\@gobble{}#1\@@@
782 \ifnum\@tempcnta=1\else
783 \PackageWarning{tablists}{Incorrect label; no or multiple
784 counters.\MessageBreak The label is: \@gobble#1}%
785 \fi
786 \expandafter\edef\csname label#2\endcsname{\the\TeXr@lab}%
787 \expandafter\let\csname the#2\endcsname\TeXr@the%
788 }
789 % \end{macrocode}
790 %
791 % For column alignment is used |\halign| command of plain \TeX.
792 % In this case \env{tabenum}/\env{rtabenum} environments can run through a few pages.
793 % \begin{macrocode}
794 \newcommand{\@TeXr@tabenum}{\begingroup
795 \let\\\TeXr@arraycr\TeXr@tlist@arrayjot\let\par=\cr
796 \settowidth\@tempdima{\tabenumindent}\gdef\tabenumindent{}%
797 \settowidth\@tempdimb{\tabenumsep}%
798 \ifnum\@listdepth>\z@\advance\@tempdima\@totalleftmargin\fi
799 \let\qedhere\tabqedhere
800 \halign\bgroup
801 \strut##\hskip\@tempdima
802 \hskip-\@tempdimb&&\hskip\@tempdimb\hfil##\hskip\labelsep
803 &##\hfil\cr}
804 % \end{macrocode}
805 %
806 % Finish of \env{tabenum} environment.
807 % \begin{macrocode}
808 \def\endtabenum{\crcr\egroup\endgroup\par
809 \addpenalty\@endparpenalty
810 \advance\@topsepadd\jot
811 \addvspace\@topsepadd}
812 % \end{macrocode}
813 % \end{environment}%
814 % \end{environment}%
815 %
816 % \begin{environment}{subtabenum}
817 % \begin{environment}{rsubtabenum}
818 % The tabulated list of second level. This list uses a real \env{tabular}
819 % environment. In this case it is placed in one page. This list as its
820 % parent environment use optional argument in the way of \package{paralist}'s
821 % \env{enumerate}.
822 % \begin{macrocode}
823 \newcommand\subtabenum[1][]{\TeXr@tlist@arrayjot
824 \setcounter{\@subenumctr}\z@
825 \def\tempa{#1}\ifx\tempa\empty\else
826 \TeXr@enumlabel@{#1}{\@subenumctr}\fi
827 \let\item\subtabenumitem\let\noitem\nosubtabenumitem
828 \let\tabenumitem\subtabenumitem\let\notabenumitem\nosubtabenumitem
829 \let\subitem\subtabenumitem\let\nosubitem\nosubtabenumitem
830 \@TeXr@subtabenum
831 }
832 \newcommand{\@TeXr@subtabenum}{\let\negtabenumsep\relax
833 \hbox{\ifnum0=`}\fi
834 \begin{tabular}[t]{@{\tabenumindent}l@{}
835 *{12}{r@{\hskip\labelsep}l@{\tabenumsep}}@{}}%
836 }
837 \def\endsubtabenum{\end{tabular}%
838 \ifnum0=`{\fi}\gdef\tabenumindent{}}
839 % \end{macrocode}
840 %
841 % Russified environment with |\Asbuk|/|\asbuk| counters instead of
842 % |\Alph|/|\alph|.
843 % \begin{macrocode}
844 \newenvironment{rsubtabenum}{\let\Alph\Asbuk\let\alph\asbuk%
845 \subtabenum}{\endsubtabenum}
846 % \end{macrocode}
847 % \end{environment}%
848 % \end{environment}%
849 %
850 % \begin{macro}{\arrayjot}
851 % The redefinition of |\\| command inside tabular to enlarge interline spacing
852 % by |\jot| value---to create analogous spacing to parent, \env{tabenum}, environment.
853 % \begin{macrocode}
854 \@ifdefinable\TeXr@rixarraycr{}
855 \let\TeXr@rixarraycr\TeXr@xarraycr
856 \newcommand\TeXr@Xarraycr{\@ifnextchar[%]
857 \TeXr@Xargarraycr {\@argarraycr[\jot]}}
858 \@ifdefinable\TeXr@Xargarraycr{}
859 \def\TeXr@Xargarraycr[#1]{\@tempdima\jot\advance\@tempdima#1%
860 \@argarraycr[\@tempdima]}
861 \@ifdefinable\TeXr@arrayjot{}
862 \def\TeXr@arrayjot [#1]{\let\@xarraycr\TeXr@Xarraycr\jot#1}
863 \def\noarrayjot{\let\@xarraycr\TeXr@rixarraycr}
864 \newcommand\TeXr@tlist@arrayjot {\@ifnextchar[%]
865 \TeXr@arrayjot{\TeXr@arrayjot[\jot]}}
866 \AtBeginDocument{\let\arrayjot\TeXr@tlist@arrayjot}
867 \def\TeXr@arraycr{%
868 \relax\iffalse{\fi\ifnum 0=`}\fi
869 \@ifstar{\vadjust{\penalty\@M}\@xarraycr}\@xarraycr}
870 % \end{macrocode}
871 % \end{macro}
872 %
873 % \begin{macro}{\startnumber}
874 % The variant of |\setcounter{enum..}{..}| sentence.
875 % This command sets start number of current list (you must put this command
876 % inside of list or \env{tabenum} environment).
877 % The |\setcounter{enum..}{..}| sentence needs previous number,
878 % but |\startnumber| needs a real start number of a list.
879 % \begin{macrocode}
880 \newcommand\startnumber[1]{\count@#1\advance\count@-1%
881 \global\expandafter\csname c@\@enumctr\endcsname\count@}
882 \newcommand\startsubnumber[1]{\count@#1\advance\count@-1%
883 \global\expandafter\csname c@\@subenumctr\endcsname\count@}
884 % \end{macrocode}
885 % \end{macro}
886 %
887 % \begin{macro}{\liststrut}
888 % For the cases of \env{tablist} appears just after empty
889 % \env{enumerate} (or analogous) list entry.
890 % This command inserts negative |\baselineskip| and put start of
891 % `tabular'ed list on the baseline of list number.
892 %
893 % Optional argument allows to align baselines in the case of high
894 % elements in first line of \env{tablist}. In the version 0.0e the calculation
895 % of compensating space was changed.
896 % \begin{macrocode}
897 \newcommand\liststrut[1][]{\def\tempa{#1}\ifx\tempa\empty
898 \strut\@tempskipa\z@
899 \else\settoheight\@tempdima{{$#1$}}\vrule height\@tempdima depth\dp\strutbox width\z@
900 \advance\@tempdima-\ht\strutbox
901 \ifdim\@tempdima>\lineskip\advance\@tempdima\lineskip\fi
902 \@tempskipa\@tempdima
903 \fi
904 \advance\@tempskipa\baselineskip
905 % \advance\@tempskipa-\@outerparskip
906 \par\nobreak\vskip-\parskip
907 % \advance\@tempskipa\lastskip
908 \nobreak\kern-\@tempskipa\@nobreaktrue}
909 % \end{macrocode}
910 % \end{macro}
911 %
912 % \begin{macro}{\tabqedhere}
913 % Places the QED sign at the end of \env{tabenum} line inside the \env{proof} environment.
914 % \begin{macrocode}
915 \newcommand\tabqedhere{\cr
916 \noalign{\@par\@tempdima\prevdepth
917 \kern-\@tempdima\kern-\baselineskip\kern\lineskip
918 {\strut\popQED}\@par\kern\@tempdima}}
919 % \end{macrocode}
920 % \end{macro}
921 %
922 % \begin{macro}{\restorelistitem}
923 % For the cases when standard lists appear inside \env{tablist}.
924 % \begin{macrocode}
925 \let\TeXr@orilistitem\item
926 \newcommand\restorelistitem{\let\item\TeXr@orilistitem}
927 % \end{macrocode}
928 % \end{macro}
929 %
930 % \Finale
931 \endinput
932 %%
933 %% End of file tablists.dtx