| 1 |
% list.tex copyright 1992 Victor Eijkhout |
| 2 |
% copyright 2014--2016 Vafa Khalighi |
| 3 |
% |
| 4 |
% |
| 5 |
% This program is free software: you can redistribute it and/or modify |
| 6 |
% it under the terms of the GNU General Public License as published by |
| 7 |
% the Free Software Foundation, either version 3 of the License, or |
| 8 |
% (at your option) any later version. |
| 9 |
% |
| 10 |
% This program is distributed in the hope that it will be useful, |
| 11 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
% GNU General Public License for more details. |
| 14 |
% |
| 15 |
% You should have received a copy of the GNU General Public License |
| 16 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
% |
| 18 |
% |
| 19 |
\Chapter Lists |
| 20 |
|
| 21 |
Lists in Lollipop are defined by \refcs{DefineList}: |
| 22 |
|
| 23 |
\Ver>\DefineList:Foo [...] |
| 24 |
item:start [...] item:stop |
| 25 |
[...] Stop<Rev |
| 26 |
and the resulting list is used as |
| 27 |
\Ver>\Foo |
| 28 |
\item [ ..text.. ] |
| 29 |
\item [ ... ] |
| 30 |
\FooStop<Rev |
| 31 |
where the closing command can be abbreviated as~\cs{>}. |
| 32 |
|
| 33 |
\Section Label alignment |
| 34 |
|
| 35 |
In general there is a default position for labels; |
| 36 |
either aligning with the |
| 37 |
left or the right side of the margin over which the list is indented. |
| 38 |
The two ways are indicated with the option \refopt{item}: |
| 39 |
\Ver> item:left [...] item:stop<Rev |
| 40 |
and \Ver> item:right [...] item:stop<Rev respectively. |
| 41 |
Specifying \opt{item:start} gives the default left aligning position. |
| 42 |
|
| 43 |
\Example |
| 44 |
\DefineList:enumerate |
| 45 |
item:start itemCounter ) item:stop Stop |
| 46 |
\DefineList:enumerateright |
| 47 |
item:right ( itemCounter ) Spaces:1 item:stop Stop |
| 48 |
\enumerate\item Some item |
| 49 |
\item And another |
| 50 |
\enumerateright\item First nested item |
| 51 |
\item Next nested item\> |
| 52 |
\item And back to the original list.\> |
| 53 |
\ExampleStop |
| 54 |
|
| 55 |
\Section List indentation |
| 56 |
|
| 57 |
The amount over which the text of a list (excluding the item labels) |
| 58 |
is indented is controled by a list of indentations. This is explained |
| 59 |
in section~\ref[sec:indent:control]. The indentation amount is most of |
| 60 |
the time also equal to the value of the paragraph indentation outside |
| 61 |
that list. |
| 62 |
|
| 63 |
In the rare case where the indentation of a list has to be controlled |
| 64 |
explicitly, there is an option \refopt{indentation} with one value. |
| 65 |
\Ver>\DefineList:SomeList indentation=30pt [...] Stop<Rev |
| 66 |
|
| 67 |
|
| 68 |
\Section Label style |
| 69 |
|
| 70 |
Every list that uses the \refopt{itemsign} option is an `itemize' list, |
| 71 |
no matter what it's name, and there is a counter in Lollipop that |
| 72 |
keeps track of how deep you are in itemize lists. Similarly, every |
| 73 |
list that uses \refopt{itemCounter} is an `enumerate' lists, and these |
| 74 |
are counted too. |
| 75 |
|
| 76 |
On every next level a new style of item sign or counter is used. For |
| 77 |
item signs this is in sequence: $\bullet$, $\circ$, --, and $\cdot$ |
| 78 |
for all higher levels. The style of sign can be changed by |
| 79 |
\refcs{SetItemSign}: \Ver>\SetItemSign:6=m<Rev where the letter |
| 80 |
indicating the sign is interpreted as: \n b~$\bullet$ (bullet), \n |
| 81 |
c~$\circ$ (circle), \n d~$\diamond$ (diamond), \n m~--- (em-dash), \n |
| 82 |
n~-- (en-dash), \n .~$\cdot$. |
| 83 |
|
| 84 |
Similarly, the counter style can be set by |
| 85 |
\refcs{SetItemCounterRepresentation}: |
| 86 |
\Ver>\SetItemCounterRepresentation:2=i<Rev where the letter |
| 87 |
representing the style is interpreted as: 1~Arabic, I~uppercase roman, |
| 88 |
i~lowercase roman, A~uppercase characters, a~lowercase characters. |
| 89 |
|
| 90 |
\Section Label width |
| 91 |
|
| 92 |
The default width for a label is at most the width of the margin over |
| 93 |
which the list is indented. Using \opt{item:left} or \opt{item:right} |
| 94 |
will have the label pushed to the left or right side of this margin |
| 95 |
respectively. Now what if the label material is wider than this |
| 96 |
margin? Usually you want the label then to expand to the right, and |
| 97 |
that is indeed what happens, unless you specify |
| 98 |
\refopt{labeloverflow} with value \n{left}, in which case the right |
| 99 |
boundary of the label will not budge, and the label will start |
| 100 |
protruding into the outer margin. |
| 101 |
|
| 102 |
\Section[sec:description:list] Description lists |
| 103 |
|
| 104 |
A common type of list is the type where each item label consists of a |
| 105 |
piece of text. Such a list is called a `description' list in |
| 106 |
\Lollipop, and it recognized by the occurrence of the option |
| 107 |
\refopt{description} in its definition. A~description list can also use |
| 108 |
the item sign or the item counter, of course. |
| 109 |
|
| 110 |
Using a description list, the description text is everything that |
| 111 |
follows the command \cs{item}, up to the end of the line. |
| 112 |
|
| 113 |
\Example |
| 114 |
\DefineList:TestList |
| 115 |
item:left Style:bold itemCounter . Spaces:1 description |
| 116 |
Spaces:2 item:stop Stop |
| 117 |
\TestList\item Do |
| 118 |
A deer, a female deer.\item Re |
| 119 |
According to mr. Fowler only a legal term. |
| 120 |
\item Mimi Jett |
| 121 |
The owner/founder of ETP\> |
| 122 |
\ExampleStop |
| 123 |
|
| 124 |
As you can see, the problem of label overflow can easily occur with |
| 125 |
description lists. Thus it is a good idea to end the item material |
| 126 |
with some white space, as in the above example. |
| 127 |
|
| 128 |
Exceptional situation: |
| 129 |
if you use an empty description text, you should write \ver>\item{}>. |
| 130 |
|
| 131 |
\Section Suspended lists |
| 132 |
|
| 133 |
Occasionally the is a need to resume an enumerate list, that is, |
| 134 |
after a piece of text that is not part of the list an enumerate list |
| 135 |
should start counting from the previous value on. In \Lollipop\ this |
| 136 |
phenomenon can be realized by never ending the enumerate list, and |
| 137 |
simply moving the text one indentation level back with |
| 138 |
\refcs{PopIndentLevel}. |
| 139 |
|
| 140 |
\Example |
| 141 |
\DefineList:enumerate item:left itemCounter item:stop Stop |
| 142 |
\enumerate\item First some item\par |
| 143 |
{\PopIndentLevel \Indent:no |
| 144 |
This text seems to be outside the list. Don't you believe it.\par} |
| 145 |
\item And another item\> |
| 146 |
\ExampleStop |
| 147 |
|
| 148 |
Note that the `popped' text has to be in a group (otherwise the |
| 149 |
subsequent items will also be popped back), and it has to be |
| 150 |
separated from the preceding and following text by \cs{par}; the |
| 151 |
trailing \cs{par} has to be in the group. |
| 152 |
|
| 153 |
\Section Item counter manipulation |
| 154 |
|
| 155 |
The item counter can be manipulated explicitly. This is necessary for |
| 156 |
instance for starting a list at another value than one. What you need |
| 157 |
to realize here is that the command \cs{item} starts by incrementing |
| 158 |
the counter. Furthermore, the only way to access the item counter is |
| 159 |
through the commands for counters; see section~\ref[sec:counters]. |
| 160 |
|
| 161 |
\Example |
| 162 |
\DefineList:enumerate item:left itemCounter item:stop Stop |
| 163 |
\enumerate \SetCounter:item=-1 |
| 164 |
\item Escape: usually the backslash. |
| 165 |
\item Begin Group.\> |
| 166 |
\ExampleStop |
| 167 |
|
| 168 |
\Section List titles and list tails |
| 169 |
|
| 170 |
Lists can have titles. The title follows the command that invokes the |
| 171 |
list, in the usual manner. Material to follow the list can also be |
| 172 |
specified: anything following the option \refopt{text} is considered to |
| 173 |
be trailing material. |
| 174 |
|
| 175 |
\Example |
| 176 |
\DefineList:TestList hrule line:start Style:bold title line:stop |
| 177 |
item:left Style:italic itemCounter item:stop |
| 178 |
text vwhite:3pt hrule Stop |
| 179 |
\TestList In the last fiscal year, have you:\par |
| 180 |
\item Eaten peanuts? \item Walked the dog? |
| 181 |
\item Bought a Frank Zappa record?\> |
| 182 |
\ExampleStop |
| 183 |
|
| 184 |
In case you wonder what happens with textual material after |
| 185 |
\opt{item:stop} and before any \opt{text}, well, that is taken to be |
| 186 |
inserted immediately after each item label. |
| 187 |
|
| 188 |
\Section Between the items |
| 189 |
|
| 190 |
There are special list options controlling what happens in between |
| 191 |
items. \Lollipop\ has an option \refopt{breakbetween}, analogous to |
| 192 |
\opt{breakbefore} and \opt{breakafter}; see |
| 193 |
section~\ref[sec:opt:penalties]. This item be default has a |
| 194 |
value of~\n{$-50$}, implying that breaks in between items |
| 195 |
should be preferred slightly over breaks in between the |
| 196 |
lines of an item. |
| 197 |
|
| 198 |
Similarly, there is an option \refopt{whitebetween} |
| 199 |
controlling the amount of white space in between items that is |
| 200 |
analogous to \opt{whitebefore} and \opt{whiteafter}. Like these two |
| 201 |
options, it can also be set by the \cs{Distance} command |
| 202 |
(section~\ref[sec:com:distance]). |
| 203 |
|
| 204 |
\Section Indentation in lists |
| 205 |
|
| 206 |
An item can be considered to be consisting of at least one paragraph. |
| 207 |
That paragraph is never indented. For the behaviour of any next |
| 208 |
paragraph within the same item, the option \refopt{indentinside} can be |
| 209 |
used. This option has values yes/no. In case paragraphs inside an |
| 210 |
item indent, the indentation amount is level-controlled; see |
| 211 |
section~\ref[sec:indent:control]. |
| 212 |
|
| 213 |
\Chapter[chap:text:block] Text Blocks |
| 214 |
|
| 215 |
The `text block' is a way of treating a moderate sized chunk of text |
| 216 |
in a different way from the surrounding text. Text blocks are |
| 217 |
created by \refcs{DefineTextBlock}. Here is a small example. |
| 218 |
|
| 219 |
\Example |
| 220 |
\DefineTextBlock:Quote |
| 221 |
PushIndentLevel PointSize:9 SetFont text Stop |
| 222 |
\Indent:no In some context it has been written that |
| 223 |
\Quote No man is an island.\QuoteStop |
| 224 |
In another: |
| 225 |
\Quote Run don't walk to the nearest island.\> |
| 226 |
Sometimes one would wish women weren't so logical. |
| 227 |
\ExampleStop |
| 228 |
|
| 229 |
Note that the text block has an explicit closing command, |
| 230 |
consisting of the name of the block followed by \opt{Stop}, |
| 231 |
and that implicit closing by \cs{>} is possible. |
| 232 |
|
| 233 |
\Section The \opt{text} option |
| 234 |
|
| 235 |
Text blocks have only one specific option: \refopt{text}. This option |
| 236 |
is used to separate material heading the block from material trailing |
| 237 |
the block. Example: |
| 238 |
|
| 239 |
\Example |
| 240 |
\DefineTextBlock:DisplayEq |
| 241 |
whitebefore:abovedisplayskip whiteafter:belowdisplayskip |
| 242 |
line:start white:parindent $ displaystyle text $ line:stop Stop |
| 243 |
The formula |
| 244 |
\DisplayEq e^{\pi i}+1=0\> |
| 245 |
contains nature's five most interesting constants. |
| 246 |
\ExampleStop |
| 247 |
|
| 248 |
Here one dollar comes before the text, and one after, so the first is |
| 249 |
inserted by \cs{DisplayEq} and the second by the corresponding |
| 250 |
closing command. |
| 251 |
|
| 252 |
Material before and after the text should usually not be broken. |
| 253 |
Hence \cs{nobreak} is automatically inserted. See the \cs{Example} |
| 254 |
macro for this manual: pages should not be broken after rules, or |
| 255 |
around the text `example~xyz'. |
| 256 |
|
| 257 |
\Section More examples |
| 258 |
|
| 259 |
A text block can encompass more than one paragraph, so the options |
| 260 |
\opt{indentinside} and \opt{indentfirst} are particularly useful here. |
| 261 |
|
| 262 |
\Example |
| 263 |
\AlwaysIndent:no |
| 264 |
\DefineTextBlock:TestBlock PushIndentLevel |
| 265 |
indentafter:yes indentfirst:no indentinside:yes |
| 266 |
text unskip hfill $ bullet $ par Stop |
| 267 |
One paragraph.\par The next paragraph |
| 268 |
\TestBlock Inside the block one paragraph.\par |
| 269 |
Inside the block the next paragraph.\> |
| 270 |
Outside the following paragraph.\par And the last paragraph. |
| 271 |
\ExampleStop |
| 272 |
|
| 273 |
\ImpNote |
| 274 |
\iSection[imp:gen:open:close] The environment in generic constructs |
| 275 |
|
| 276 |
The text block is just about the purest use of the \Lollipop\ |
| 277 |
environment mechanism. Here is how a text block is defined: |
| 278 |
\Ver> |
| 279 |
\def\@DefineTextBlock{ |
| 280 |
\csarg\edef{\@name}{\@gen@open |
| 281 |
\the\before@coms |
| 282 |
} |
| 283 |
\@DefineStopCommand{\the\after@coms \@gen@close} |
| 284 |
}<Rev |
| 285 |
|
| 286 |
The \cs{before@coms} and \cs{after@coms} are two token lists with |
| 287 |
the heading and trailing commands. |
| 288 |
|
| 289 |
It is important to note that the definition of the control sequence |
| 290 |
of the block is defined by \cs{edef}. This first of all unwraps the |
| 291 |
token lists, but it also has an important effect on |
| 292 |
\cs{@gen@open/close}. These control sequences contain a lot of |
| 293 |
conditionals which, in combination with the \cs{edef} give a really |
| 294 |
dynamic definition of generic constructs in \Lollipop. |
| 295 |
|
| 296 |
First of all, the opening and closing commands induce a group |
| 297 |
so that various quantities can be set locally. |
| 298 |
\Ver> |
| 299 |
\def\@gen@open{\outer@start@commands |
| 300 |
\begingroup \inner@start@commands} |
| 301 |
\def\@gen@close{\inner@end@commands |
| 302 |
\endgroup \outer@end@commands}<Rev |
| 303 |
|
| 304 |
The outer start commands concern global actions such as backspacing |
| 305 |
previous skips, incrementing counters and setting references. |
| 306 |
\Ver> |
| 307 |
\def\outer@start@commands{% |
| 308 |
\iftext@construct |
| 309 |
\ifleft@embedded@construct |
| 310 |
\nxp\bsp@hack |
| 311 |
\else \nxp\leavehmode \nxp\bvwit{\the\@whitebefore}\fi<Rev |
| 312 |
The `embedded construct' tests are only true if the construct |
| 313 |
can be embedded in a paragraph. A~rare occurence most of the time. |
| 314 |
\Ver> |
| 315 |
% backspace previous white space while it's visible |
| 316 |
\nxp\if@headed\nxp\else |
| 317 |
\ifforced@break@before\@beforepenalty |
| 318 |
\else\nxp\ifnum\lastpenalty=\z@ |
| 319 |
\@beforepenalty\nxp\fi |
| 320 |
\fi |
| 321 |
\nxp\fi<Rev |
| 322 |
A subtle point: a preceding heading will have placed \cs{nobreak} |
| 323 |
followed by a skip. It is dangerous to place any sort of penalty |
| 324 |
after this because it might induce a page break. |
| 325 |
|
| 326 |
Now the counter, title, and stuff connected to that. |
| 327 |
\Ver> |
| 328 |
\fi |
| 329 |
\ifhas@counter \nxp\StepCounter:\expandafter\@name\@space |
| 330 |
% This sets the \current@label by default<Rev |
| 331 |
Since this is used inside an \cs{edef} we can use some trickery |
| 332 |
to get the space token after the argument to \cs{StepCounter}. |
| 333 |
\Ver> |
| 334 |
\ifhas@marks \edef\nxp\cs@e |
| 335 |
{\nxp\nxp\nxp\refresh@mark@item |
| 336 |
{\@name Counter}{\CSname{\@name Counter}}}% |
| 337 |
\nxp\cs@e |
| 338 |
\fi |
| 339 |
\fi |
| 340 |
\iflabel@defined |
| 341 |
\global\current@label={\the\@labelcoms}\fi |
| 342 |
\ifhas@title \install@title@code<Rev |
| 343 |
This title business is explained in~\ref[imp:install:title]. |
| 344 |
This piece of code also refreshes the title in the mark structure. |
| 345 |
This has to be done after any page break for the benefit |
| 346 |
of headers/footers. |
| 347 |
\Ver> |
| 348 |
\fi |
| 349 |
\ifhas@marks\nxp\ifnin{\nxp\place@mark}\fi |
| 350 |
%otherwise IniTeX'ing Lollipop will output a page |
| 351 |
\nxp\xx@label\the\extern@toks\penalty\@M |
| 352 |
% also subtle: if this white space would be higher, it would |
| 353 |
% be invisible because of marks et cetera. |
| 354 |
% insert nobreak after marks/writes to prevent page breaks. |
| 355 |
\iftext@construct |
| 356 |
\ifleft@embedded@construct |
| 357 |
\else \nxp\@vwhite{\the\@whitebefore}\fi |
| 358 |
\fi |
| 359 |
}<Rev |
| 360 |
|
| 361 |
Inner start commands are concerned with setting local values. |
| 362 |
\Ver> |
| 363 |
\def\inner@start@commands{% |
| 364 |
\nxp\Open@Group\CSname{\@class}\CSname{\@name}%<Rev |
| 365 |
The \cs{Open@Group} call makes it possible to track down groups |
| 366 |
that have inadvertendly been left open. Since we now know the |
| 367 |
name we can give helpful error msgs. |
| 368 |
\Ver> |
| 369 |
\install@stop<Rev |
| 370 |
Install the right implicit closing, see~\ref[sec:implicit:close] |
| 371 |
and~\ref[imp:implicit:close]. |
| 372 |
\Ver> |
| 373 |
\ifleft@embedded@construct |
| 374 |
\else \nxp\hold@parskip |
| 375 |
\nxp\@defaulteverypar |
| 376 |
\ifwhiteleft@defined \advance\leftskip \the\@whiteleft \relax \fi |
| 377 |
\ifwhiteright@defined \advance\rightskip \the\@whiteright \relax \fi |
| 378 |
\nxp\let\nxp\par=\nxp\@par %explain to me again why this is necessary... |
| 379 |
\inside@indent \first@indent |
| 380 |
\fi |
| 381 |
\advance\nest@depth\@ne<Rev |
| 382 |
The nest depth is used for determining indentation levels. |
| 383 |
\Ver> |
| 384 |
}<Rev |
| 385 |
|
| 386 |
End commands set up some conditions, most of which will be tested |
| 387 |
by the start of any next construct. |
| 388 |
\Ver> |
| 389 |
\def\inner@end@commands{% |
| 390 |
\nxp\Close@Group\CSname{\@class}\CSname{\@name}% |
| 391 |
\ifright@embedded@construct \else \nxp\leavehmode \fi |
| 392 |
\@afterpenalty |
| 393 |
\ifright@embedded@construct \else \nxp\@vwhite{\the\@whiteafter}\fi |
| 394 |
} |
| 395 |
\def\outer@end@commands{% |
| 396 |
\the\after@toks |
| 397 |
\ifright@embedded@construct |
| 398 |
\nxp\@headedno \nxp\esp@hack |
| 399 |
\else |
| 400 |
\after@indent \nxp\dono@parskip |
| 401 |
\fi}<Rev |
| 402 |
|
| 403 |
\iSection[imp:implicit:close] Implicit closing |
| 404 |
|
| 405 |
Constructs with an explicit closing command, lists and text blocks, |
| 406 |
can be closed by~\cs{>}, which simply closes the current |
| 407 |
construct. A~more drastic version, \cs{>]}, closes all currently |
| 408 |
open constructs. |
| 409 |
\Ver> |
| 410 |
\def\outer@stop@command{\Emessage{Vacuous group closing}} |
| 411 |
\let\default@stop@command\outer@stop@command |
| 412 |
\def\>{\default@stop@command%[fool the editor |
| 413 |
\ifNextChar]{% |
| 414 |
\ifx\default@stop@command\outer@stop@command |
| 415 |
\xp\take@one |
| 416 |
\else \xp\>\fi}{}}<Rev |
| 417 |
The \cs{outer@stop@command} is meant to give an error msg if the |
| 418 |
user attempts to close a group while none is open. |
| 419 |
|
| 420 |
The current meaning of~\cs{>} is installed in |
| 421 |
\cs{inner@start@commands}: |
| 422 |
\Ver> |
| 423 |
\def\install@stop{\if@implicitclose |
| 424 |
\def\nxp\default@stop@command |
| 425 |
{\CSname{\stop@command}}% |
| 426 |
\else \let\nxp\default@stop@command |
| 427 |
\nxp\outer@stop@command |
| 428 |
\fi}<Rev |
| 429 |
|
| 430 |
By default, constructs can be closed implicitly, but there is an |
| 431 |
option \refopt{noimplicitclose} to disable this. |
| 432 |
\Ver> |
| 433 |
\newif\if@implicitclose |
| 434 |
\add@generic@default{\@implicitcloseyes} |
| 435 |
\@GenericOption{noimplicitclose}{\@implicitcloseno}<Rev |
| 436 |
This option is for instance used in the examples in this manual. |
| 437 |
Otherwise closing a construct in the example would also close the |
| 438 |
example itself. |
| 439 |
|
| 440 |
\ImpNoteStop |
| 441 |
|
| 442 |
\endinput |