summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/texpower/tplists.sty
blob: 8b9212b7102e41b712759d3699ca4bc119c2fbef (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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
%%
%% This is file `tplists.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% texpower-addons.dtx  (with options: `tplists')
%% 
%% --------------------------------------------------------------
%% TeXPower bundle - dynamic online presentations with LaTeX
%% Copyright (C) 1999-2004 Stephan Lehmke
%% 
%% This program is free software; you can redistribute it and/or
%% modify it under the terms of the GNU General Public License
%% as published by the Free Software Foundation; either version 2
%% of the License, or (at your option) any later version.
%% 
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%% GNU General Public License for more details.
%% --------------------------------------------------------------
%% 
%% The list of all files belonging to the TeXPower bundle is
%% given in the file `00readme.txt'.
%% 
% ===============================================================================
% File:      tplists.sty
%
% Function:  The package provides dynamic lists. The following
%            environments/lists are available
%            1) 'stepenum', 'stepitem', 'stepeqlist', 'stepcompactenum'
%               'stepcompactitem' and 'stepcompacteqlist'.
%            2) 'flipenum', 'flipitem', 'flipeqlist', 'flipcompactenum',
%               'flipcompactitem',  and 'flipcompacteqlist'
%            3) 'dimenum', 'dimitem', 'dimeqlist', 'dimcompactenum',
%               'dimcompactitem',  and 'dimcompacteqlist'
%            where 'step' is short for stepped, 'flip' for flipped and
%            'dim' for dimmed. The packages 'paralist' and 'eqlist'
%            must be loaded before this package to use the *eqlist and
%            *compact* lists.
%
% Usage:     The package is loaded in the normal fashion, eg:
%              \usepackage{tplists}
%            The following options exist:
%              pausestep - makes step* lists use \pause
%            The package works better (the lists look better) if TeXPower
%            uses colors.
%
%            All lists (except *eqlist) takes an optional parameter
%            adding to the indent of the list. Note that dim* and
%            flip* lists do not nest, and that step* lists inside
%            dim*/flip* will behave as a dim*/flip* list respectively.
%
%            Example:
%
%              \documentclass[a4paper]{article}
%              \usepackage[darkbackground,display]{texpower}
%              \usepackage{tplists}
%              \begin{document}
%              \begin{flipitem}[2cm]
%                \item Before
%                  \begin{enumerate}[1cm]
%                    \item An item
%                    \item Another item
%                   \end{enumerate}
%                \item After
%              \end{flipitem}
%              \end{document}
%
%            (The normal 'itemize' and 'enumerate' lists are modified
%            so they accept the optional parameter and work nested
%            with the new lists.)
%
% Issues:    The step* lists use \vstep (as default) which give weird results with
%            structured backgrounds. Using the pausestep option fixes this, but then
%            you can't nest step* lists inside dim* or flip* lists.
%            There are also some unresolved problems when using french babel.
%
% History:   2003/10/03 v0.1:
%              * first public release
%            2003/10/04 v0.1a:
%              * removed redefinition of eqlist (since it doesn't work)
%            2003/10/07 v0.1b:
%              * corrected some typos in this documentation
%              * added option pausestep
%              * made dim* (and all variants of flip*) lists work without
%                colors by using boldface for active items.
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tplists}%
  [2003/10/07 v0.1b Dynamic Lists using TeXPower]

%% Packages
\RequirePackage{texpower}
% Compact enum/item.
\newboolean{tpl@paralist}
\@ifpackageloaded{paralist}{\setboolean{tpl@paralist}{true}}{}
% Lists with equal indentation.
\newboolean{tpl@eqlist}
\@ifpackageloaded{eqlist}{\setboolean{tpl@eqlist}{true}}{}

%% Options
% Use \pause for steplists (too avoid problems with structured backgrounds).
\newboolean{tpl@pausestep}
\DeclareOption{pausestep}{\setboolean{tpl@pausestep}{true}}

\ProcessOptions

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                  %
%  Flipped/dimmed/stepped itemize/enumerate/eqlist environment.    %
%                                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% '\iftpl@instepenv' indicates if we are in some kind of stepped list
% environment. '\iftpl@indimenv' / '\tpl@inflipenv' indicates that we are
% using one of the stepwise environments from texpower (that doesn't
% nest). '\iftpl@inpausestepenv' indicates that we are in a stepped
% list that uses \pause.

% using 'tpl@' as prefix for internals.
\newif\iftpl@instepenv \tpl@instepenvfalse
\newif\iftpl@inpausestepenv \tpl@inpausestepenvfalse
\newif\iftpl@indimenv  \tpl@indimenvfalse
\newif\iftpl@inflipenv \tpl@inflipenvfalse
\let\oldenumerate=\enumerate
\let\olditemize=\itemize
\let\endoldenumerate=\endenumerate
\let\endolditemize=\enditemize
\ifthenelse{\boolean{tpl@eqlist}}{%
\let\oldeqlist=\eqlist
\let\endoldeqlist=\endeqlist
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\let\oldcompactenum=\compactenum
\let\oldcompactitem=\compactitem
\let\endoldcompactenum=\endcompactenum
\let\endoldcompactitem=\endcompactitem
}{}

%%% Defining \tpl@collect@body - command used to scan the list
%%% environments. Definition borrowed from 'amsmath.sty' - slightly
%%% modified to allow for 'long' arguments
\let\tpl@nx\noexpand
\let\tpl@xp\expandafter
\newtoks\tpl@emptytoks
\newtoks\tpl@envbody
\long\def\tpl@addto@envbody#1{\global\tpl@envbody\tpl@xp{\the\tpl@envbody#1}}
\def\tpl@collect@body#1{%
  \tpl@envbody{\tpl@xp#1\tpl@xp{\the\tpl@envbody}}%
  \edef\tpl@process@envbody{\the\tpl@envbody\tpl@nx\end{\@currenvir}}%
  \tpl@envbody\tpl@emptytoks \def\begin@stack{b}%
  \begingroup
  \tpl@xp\let\csname\@currenvir\endcsname\tpl@collect@@body
  \edef\tpl@process@envbody{\tpl@xp\tpl@nx\csname\@currenvir\endcsname}%
  \tpl@process@envbody
}
\long\def\tpl@push@begins#1\begin#2{%
  \ifx\end#2\else b\tpl@xp\tpl@push@begins\fi
}
\long\def\tpl@collect@@body#1\end#2{%
  \edef\begin@stack{\tpl@push@begins#1\begin\end \tpl@xp\@gobble\begin@stack}%
  \ifx\@empty\begin@stack
    \endgroup
    \@checkend{#2}%
    \tpl@addto@envbody{#1}%
  \else
    \tpl@addto@envbody{#1\end{#2}}%
  \fi
  \tpl@process@envbody
}

%%% Defining command '\tpl@addmargin' used to add a length to
%%% the leftmargin of the current level in a list.
\def\tpl@addmargin#1{%
  \advance\@listdepth 1
  \addtolength{\csname leftmargin\romannumeral\@listdepth\endcsname}{#1}
  \advance\@listdepth -1
}

%%% Defining a flipped step command.
\ifthenelse{\boolean{TPcolor}}% Can we use colors?
{% Yes. In this case highlighting is implemented by switching color.
  \def\tpl@flipstep% Note that \tpl@flipstep takes no argument.
  {%
    \step{\ifthenelse{\boolean{firstactivation}}%
      {\color{textcolor}}%
      {\color{inactivecolor}}%
    }%
    }%
}
{% No. In this case highlighting is implemented by putting the item in boldface.
  \def\tpl@flipstep
  {%
    \step{\ifthenelse{\boolean{firstactivation}}%
    {\bfseries}{\mdseries}}
    }%
  }

%%% Defining a dimmed step command.
\ifthenelse{\boolean{TPcolor}}% Can we use colors?
{% Yes. In this case highlighting is implemented by using \dstep
  \def\tpl@dimstep% Note that \tpl@flipstep takes no argument.
  {%
    \dstep
    }%
}
{% No. In this case highlighting is implemented by putting the item in boldface.
  \def\tpl@dimstep
  {%
    \step{\bfseries}
    \ifthenelse{\boolean{active}}{}{\mdseries}%
    }%
  }

%%% Defining flipped stepped - itemize / enumerate / eqlist
%%% compact itemize / compact enumerate / compact eqlist - environments.
\newenvironment{flipitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@flipitem}%
 {\global\@ignoretrue}
\newenvironment{flipenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@flipenum}%
 {\global\@ignoretrue}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newenvironment{flipeqlist}[1][0cm]{%
  \tpl@collect@body\@flipeqlist}%
 {\global\@ignoretrue}
\newenvironment{flipcompacteqlist}[1][0cm]{%
  \tpl@collect@body\@flipcompacteqlist}%
 {\global\@ignoretrue}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newenvironment{flipcompactitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@flipcompactitem}%
 {\global\@ignoretrue}
\newenvironment{flipcompactenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@flipcompactenum}%
 {\global\@ignoretrue}
}{}

\newcommand\@fliplist[2]{%
  \iftpl@indimenv
    \PackageError{tplists}{%
      dim* and flip* environments do NOT nest}{%
      Do not continue! Type 'q' to stop and fix the nested list.
    }
  \else\iftpl@instepenv
    \begin{#1}
    \let\hidestepcontents=\displaystepcontents
    \renewcommand{\item}{\tpl@flipstep\tpl@origitem}%
    #2
    \end{#1}%
  \else
    \iftpl@inpausestepenv\let\liststepwise=\stepwise\fi
    \liststepwise[\let\hidestepcontents=\displaystepcontents]{%
      \begin{#1}
      \iftpl@inpausestepenv\else
        \iftpl@instepenv\else\let\tpl@origitem=\item\fi
      \fi
      \tpl@instepenvtrue
      \tpl@inflipenvtrue
      \renewcommand{\item}{\tpl@flipstep\tpl@origitem}%
      #2
      \step{}
      \end{#1}}
  \fi\fi
}

\newcommand\@flipitem[1]{%
 \@fliplist{olditemize}{#1}}
\newcommand\@flipenum[1]{%
 \@fliplist{oldenumerate}{#1}}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newcommand\@flipeqlist[1]{%
 \@fliplist{oldeqlist}{#1}}
\newcommand\@flipcompacteqlist[1]{%
 \@fliplist{compacteqlist}{#1}}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newcommand\@flipcompactitem[1]{%
 \@fliplist{oldcompactitem}{#1}}
\newcommand\@flipcompactenum[1]{%
 \@fliplist{oldcompactenum}{#1}}
}{}

%%% Defining dimmed stepped - itemize / enumerate / eqlist /
%%% compact itemize / compact enumerate / compact eqlist - environments.
\newenvironment{dimitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@dimitem}%
 {\global\@ignoretrue}
\newenvironment{dimenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@dimenum}%
 {\global\@ignoretrue}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newenvironment{dimeqlist}[1][0cm]{%
  \tpl@collect@body\@dimeqlist}%
 {\global\@ignoretrue}
\newenvironment{dimcompacteqlist}[1][0cm]{%
  \tpl@collect@body\@dimcompacteqlist}%
 {\global\@ignoretrue}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newenvironment{dimcompactitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@dimcompactitem}%
 {\global\@ignoretrue}
\newenvironment{dimcompactenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@dimcompactenum}%
 {\global\@ignoretrue}
}{}

\newcommand\@dimlist[2]{%
  \iftpl@inflipenv
    \PackageError{tplists}{%
      dim* and flip* environments do NOT nest}{%
      Do not continue! Type <q> to stop and fix the nested list.
    }
  \else\iftpl@instepenv
    \begin{#1}
    \renewcommand{\item}{\tpl@dimstep\tpl@origitem}%
    #2
    \end{#1}%
  \else
    \iftpl@inpausestepenv\let\liststepwise=\stepwise\fi
    \liststepwise{%
      \begin{#1}
      \iftpl@inpausestepenv\else
        \iftpl@instepenv\else\let\tpl@origitem=\item\fi
      \fi
      \tpl@instepenvtrue
      \tpl@indimenvtrue
      \renewcommand{\item}{\tpl@dimstep\tpl@origitem}%
      #2
      \end{#1}}
  \fi\fi
}

\newcommand\@dimitem[1]{%
 \@dimlist{olditemize}{#1}}
\newcommand\@dimenum[1]{%
 \@dimlist{oldenumerate}{#1}}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newcommand\@dimeqlist[1]{%
 \@dimlist{oldeqlist}{#1}}
\newcommand\@dimcompacteqlist[1]{%
 \@dimlist{compacteqlist}{#1}}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newcommand\@dimcompactitem[1]{%
 \@dimlist{oldcompactitem}{#1}}
\newcommand\@dimcompactenum[1]{%
 \@dimlist{oldcompactenum}{#1}}
}{}

%%% Defining stepped - itemize / enumerate / eqlist /
%%% compact itemize / compact enumerate / compact eqlist - environments.
\newenvironment{stepitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@stepitem}%
 {\global\@ignoretrue}
\newenvironment{stepenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@stepenum}%
 {\global\@ignoretrue}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newenvironment{stepeqlist}[1][0cm]{%
  \tpl@collect@body\@stepeqlist}%
 {\global\@ignoretrue}
\newenvironment{stepcompacteqlist}[1][0cm]{%
  \tpl@collect@body\@stepcompacteqlist}%
 {\global\@ignoretrue}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newenvironment{stepcompactitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@stepcompactitem}%
 {\global\@ignoretrue}
\newenvironment{stepcompactenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \tpl@collect@body\@stepcompactenum}%
 {\global\@ignoretrue}
}{}

\ifthenelse{\boolean{tpl@pausestep}}{%
% Using \pause for step* lists
\newcommand\@steplist[2]{%
  \iftpl@inflipenv
    \PackageError{tplists}{%
      flip* followed by step* environment does NOT work \MessageBreak
      when the pausestep option is used}{%
      Do not continue! Type <q> to stop and fix the nested list.
    }
  \else\iftpl@indimenv
    \PackageError{tplists}{%
      dim* followed by step* environment does NOT work \MessageBreak
      when the pausestep option is used}{%
      Do not continue! Type <q> to stop and fix the nested list.
    }
  \else
    \begin{#1}
      \iftpl@inpausestepenv\else\let\tpl@origitem=\item\fi
      \tpl@inpausestepenvtrue
      \renewcommand{\item}{\pause\tpl@origitem}%
      #2
    \end{#1}
  \fi\fi
}
}{
% Using \liststepwise for step* lists
\newcommand\@steplist[2]{%
  \iftpl@inflipenv
    \begin{#1}
    \renewcommand{\item}{\tpl@flipstep\tpl@origitem}
    #2
    \end{#1}%
  \else\iftpl@indimenv
    \begin{#1}
    \renewcommand{\item}{\dstep\tpl@origitem}%
    #2
    \end{#1}%
  \else\iftpl@instepenv
    \begin{#1}
    \renewcommand{\item}{\vstep\tpl@origitem}%
    #2
    \end{#1}%
  \else
    \liststepwise{%
      \begin{#1}
      \iftpl@instepenv\else\let\tpl@origitem=\item\fi
      \tpl@instepenvtrue
      \renewcommand{\item}{\vstep\tpl@origitem}%
      #2
      \end{#1}}
  \fi\fi\fi
}
}

\newcommand\@stepitem[1]{%
 \@steplist{olditemize}{#1}}
\newcommand\@stepenum[1]{%
 \@steplist{oldenumerate}{#1}}
\ifthenelse{\boolean{tpl@eqlist}}{%
\newcommand\@stepeqlist[1]{%
 \@steplist{oldeqlist}{#1}}
\newcommand\@stepcompacteqlist[1]{%
 \@steplist{compacteqlist}{#1}}
}{}
\ifthenelse{\boolean{tpl@paralist}}{%
\newcommand\@stepcompactitem[1]{%
 \@steplist{oldcompactitem}{#1}}
\newcommand\@stepcompactenum[1]{%
 \@steplist{oldcompactenum}{#1}}
}{}

%%% Defining compact eqlist
\newenvironment{compacteqlist}[1][0cm]{%
  % \tpl@addmargin{#1}
  \begin{eqlist}[\parsep0pt\itemsep0pt]}%
 {\end{eqlist}}


%%% Redefining enumerate and itemize to handle changes made by
%%% introducing steps and leftmargini-option.
\renewenvironment{enumerate}[1][0cm]{%
  \tpl@addmargin{#1}
  \begin{oldenumerate}
    \iftpl@instepenv
      \renewcommand{\item}{\tpl@origitem}%
    \fi
 }%
 {\end{oldenumerate}}

\renewenvironment{itemize}[1][0cm]{%
  \tpl@addmargin{#1}
  \begin{olditemize}
    \iftpl@instepenv
      \renewcommand{\item}{\tpl@origitem}%
    \fi
 }%
 {\end{olditemize}}

%%% Redefining compactenum and compactitem to handle changes made by
%%% introducing steps and leftmargini-option.
\ifthenelse{\boolean{tpl@paralist}}{%
\renewenvironment{compactenum}[1][0cm]{%
  \tpl@addmargin{#1}
  \begin{oldcompactenum}
    \iftpl@instepenv
      \renewcommand{\item}{\tpl@origitem}%
    \fi
 }%
 {\end{oldcompactenum}}

\renewenvironment{compactitem}[1][0cm]{%
  \tpl@addmargin{#1}
  \begin{oldcompactitem}
    \iftpl@instepenv
      \renewcommand{\item}{\tpl@origitem}%
    \fi
 }%
 {\end{oldcompactitem}}
}{}
\endinput
%%
%% End of file `tplists.sty'.