| 1 |
% comm.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 Commands |
| 20 |
|
| 21 |
\Section[sec:counters] Counters |
| 22 |
|
| 23 |
Counters can be declared explicitly by the user, but more often they |
| 24 |
are defined automatically in some generic construct: |
| 25 |
|
| 26 |
The \cs{Foo} defined by |
| 27 |
\Ver>\DefineBar:Foo ... |
| 28 |
counter:i ... |
| 29 |
Stop<Rev |
| 30 |
|
| 31 |
will have a counter that counts in roman lowercase, and which is |
| 32 |
accessible as \refcs{FooCounter}. Everytime \cs{Foo} is used, this |
| 33 |
counter is increased by one. |
| 34 |
|
| 35 |
The use of the \opt{counter} option is described |
| 36 |
in~\ref[sec:opt:counter]. |
| 37 |
Here are the commands for explicit manipulation of counters. |
| 38 |
|
| 39 |
\SubSection[sec:counter:repr] Allocation and representation |
| 40 |
|
| 41 |
A counter is created by for instance |
| 42 |
\Ver>\NewCounter:Things<Rev |
| 43 |
This will create control sequence \cs{ThingsCounter} that will print |
| 44 |
the value of the counter. |
| 45 |
The counter will usually be printed as an Arabic numeral, but other |
| 46 |
counter representations can be specified by |
| 47 |
\refcs{CounterRepresentation}. Here are their codes: \Description |
| 48 |
\item 1 |
| 49 |
numeric |
| 50 |
\item a |
| 51 |
lowercase character |
| 52 |
\item A |
| 53 |
uppercase character |
| 54 |
\item i |
| 55 |
lowercase roman |
| 56 |
\item I |
| 57 |
lowercase roman |
| 58 |
\> |
| 59 |
for instance |
| 60 |
\Ver>\CounterRepresentation:Things=i<Rev |
| 61 |
will cause \cs{ThingsCounter} to print a lowercase Roman numeral. |
| 62 |
|
| 63 |
However, a call such as |
| 64 |
\Ver>\CounterRepresentation:Theorem=Lemma<Rev |
| 65 |
will make the \cs{TheoremCounter} a synonym of an earlier created |
| 66 |
\cs{LemmaCounter} |
| 67 |
|
| 68 |
\SubSection Counter manipulation |
| 69 |
|
| 70 |
The following commands can be used to manipulate counters, both when |
| 71 |
they are created by hand using \refcs{NewCounter} and when they were |
| 72 |
generated automatically in some generic construct: |
| 73 |
|
| 74 |
With \refcs{StartCounter} reset the counter to one: |
| 75 |
\Ver>\StartCounter:things<Rev |
| 76 |
|
| 77 |
With \refcs{StepCounter} increase the counter by one: |
| 78 |
\Ver>\StepCounter:things<Rev |
| 79 |
|
| 80 |
With \refcs{BackStepCounter} decrease the counter by one: |
| 81 |
\Ver>\BackStepCounter:things<Rev |
| 82 |
|
| 83 |
With \refcs{SetCounter} set the counter to some specified value: |
| 84 |
\Ver>\SetCounter:things=5<Rev |
| 85 |
|
| 86 |
With \refcs{AddToCounter} increase the counter by some |
| 87 |
specified value: |
| 88 |
\Ver>\AddToCounter:things=7<Rev |
| 89 |
|
| 90 |
The last two commands accept names of numerical parameters, for |
| 91 |
instance the value of a counter: |
| 92 |
\Ver>\NewCounter:Favourite |
| 93 |
\AddToCounter:things=FavouriteValue<Rev |
| 94 |
More about this `value' thing in the next section. |
| 95 |
|
| 96 |
\SubSection What do you get when you define a counter? |
| 97 |
|
| 98 |
After you define a counter as \Ver>\NewCounter:MyThings<Rev there are |
| 99 |
two commands that it is important to distinguish between. First of |
| 100 |
all, \cs{MyThingsCounter} gives the {\it printed\/} value of the |
| 101 |
counter. This is the command that you will use mostly. It uses |
| 102 |
whatever representation you have specified for the counter, or plain |
| 103 |
Arabic numerals if haven't specified anything. |
| 104 |
|
| 105 |
Secondly, \cs{MyThingsValue} gives the value of the counter. You can |
| 106 |
not use this command on its own: you will get a `number expected' |
| 107 |
error. |
| 108 |
|
| 109 |
\SubSection Counter hierarchies |
| 110 |
|
| 111 |
Often counters are related to each other. For instance, when a new |
| 112 |
section begins, the subsection counter has to be reset. The same may |
| 113 |
be true for equation counters. In Lollipop such a relation is |
| 114 |
indicated by a call to \refcs{GoverningCounter}, for instance |
| 115 |
|
| 116 |
\Ver>\GoverningCounter:SubSection=Section<Rev |
| 117 |
|
| 118 |
All of the counter manipulation commands applied to a governing |
| 119 |
counter will cause all governed counters to be reset. Such a reset |
| 120 |
also occurs if the counter was created in some generic construct. |
| 121 |
|
| 122 |
For examples, see section~\ref[sec:head:examples]. |
| 123 |
|
| 124 |
\SubSection Referencing counters |
| 125 |
|
| 126 |
All counters that are declared as part of a generic construct, or |
| 127 |
explicitly through \refcs{NewCounter} automatically become the current |
| 128 |
reference when they are altered. Thus \ver>\label[bar]> will make |
| 129 |
\ver>\ref[bar]> refer to the value of the counter most recently |
| 130 |
changed. The way the counter is referenced can be altered by the |
| 131 |
\opt{label} option in generic constructs; see |
| 132 |
section~\ref[sec:opt:label]. |
| 133 |
|
| 134 |
For generic constructs with a counter no explicit \refcs{label} commands |
| 135 |
need to be given; such commands take an optional argument with the |
| 136 |
label key: |
| 137 |
\Ver>\Section[sec:examples] Examples<Rev |
| 138 |
|
| 139 |
\SubSection Adaptive counters |
| 140 |
|
| 141 |
It may happen that you want to compute a value during one run of |
| 142 |
\TeX, and use it in the next. An example is the fact that this manual |
| 143 |
states the total number of pages on the title page. For this you can |
| 144 |
use \refcs{AdaptiveCounter} |
| 145 |
\Ver>\AdaptiveCounter:LastPage<Rev |
| 146 |
which is like \cs{NewCounter}, except that the value of this counter |
| 147 |
gets written to the \file{.aux} file. |
| 148 |
|
| 149 |
There are two ways of setting an adaptive counter: you can simply use |
| 150 |
it in some construct (for instance through a counter synonym; |
| 151 |
section~ref[sec:counter:repr]), or you can set it explicitly, for |
| 152 |
instance as |
| 153 |
\Ver>\SetCounter:LastPage=PageValue<Rev |
| 154 |
See how this manual does it. |
| 155 |
|
| 156 |
\SubSection Examples of counter usage |
| 157 |
|
| 158 |
Items start at the value of one, so if a starting value of zero is |
| 159 |
necessary, the following will work |
| 160 |
\Ver> |
| 161 |
\Enumerate \SetCounter:item=-1 |
| 162 |
\item ...<Rev |
| 163 |
|
| 164 |
|
| 165 |
\Section[sec:font] Font selection |
| 166 |
|
| 167 |
In \Lollipop, choosing a font is done through three parameters: |
| 168 |
\Description\item Typeface |
| 169 |
A collection of related styles and sizes. The typeface is set by the |
| 170 |
command \refcs{Typeface}. |
| 171 |
\item Style |
| 172 |
Italic, bold, roman, typewriter. You know. The style is set by the |
| 173 |
command \refcs{Style}. |
| 174 |
\item PointSize |
| 175 |
The size of a font in typographical points ($72.27$ per inch). |
| 176 |
The pointsize is set by the command \refcs{PointSize}. |
| 177 |
\> |
| 178 |
|
| 179 |
The most common change of font is a change in style. Therefore, |
| 180 |
issuing a command such as \Ver>\Style:bold<Rev immediately changes |
| 181 |
the font to the bold of the current typeface in the current pointsize. |
| 182 |
|
| 183 |
However, issuing a command such as \Ver>\Typeface:GoudyOldStyle<Rev |
| 184 |
or \Ver>\PointSize:28<Rev will not change the font, since such |
| 185 |
changes are usually accompanied by a change in style. In case that an |
| 186 |
immediate switch is necessary, the command |
| 187 |
\refcs{SetFont} can be given. |
| 188 |
This evaluates the current value of the typeface, style, and |
| 189 |
pointsize commands, and sets the font accordingly. |
| 190 |
|
| 191 |
A number of typeface names have been predefined in \Lollipop, |
| 192 |
however, in order to print them your printer (software) must have them |
| 193 |
available. |
| 194 |
|
| 195 |
\Example |
| 196 |
\SerifFace \PointSize:12 |
| 197 |
\Style:roman This \Style:italic sentence \PointSize:10 has |
| 198 |
\SetFont way \SansFace \Style:roman too \SetFont many |
| 199 |
\PointSize:12 \SetFont font \Style:bold changes. |
| 200 |
\ExampleStop |
| 201 |
|
| 202 |
(The commands \cs{SerifFace} and \cs{SansFace} are defined in |
| 203 |
the master file of this manual, and serve to make this manual |
| 204 |
formattable on any system.) |
| 205 |
|
| 206 |
\SubSection Relative size changes |
| 207 |
|
| 208 |
Apart from setting the pointsize explicitly, it is also possibly to |
| 209 |
make size changes relative to the current size. For instance, |
| 210 |
\refcs{PointSizeLarger} and \refcs{PointSizeSmaller} with an optional |
| 211 |
argument indicating the size of the change can be used. These |
| 212 |
commands are not cumulative. |
| 213 |
|
| 214 |
\Example |
| 215 |
\SerifFace |
| 216 |
\PointSize:9 \SetFont Every once in a while,\SaveFont |
| 217 |
\PointSizeLarger[2] shouting \PointSizeLarger helps. |
| 218 |
\PointSizeSmaller[2]But most of the times it doesn't. |
| 219 |
\RestoreFont Unfortunately. |
| 220 |
\ExampleStop |
| 221 |
|
| 222 |
Similar to the changes in mathematics mode to script and scriptscript |
| 223 |
size, the same relative changes are available in text mode through |
| 224 |
the control sequences \refcs{script} and \refcs{scriptscript}. |
| 225 |
The control |
| 226 |
sequence \refcs{normal} can be used to restore the default size. |
| 227 |
|
| 228 |
Here is one application of such relative changes: |
| 229 |
\Ver> |
| 230 |
L\kern -.3em\raise .35ex\hbox {\script A}\kern -.1em\TeX<Rev |
| 231 |
which gives definition of the \LaTeX\ logo that is independent |
| 232 |
of typeface, size and style. |
| 233 |
|
| 234 |
The relative sizes of script and scriptscript fonts are by default at |
| 235 |
$70\%$ and $50\%$, but they can be set explicitly by |
| 236 |
\Ver>\PointSizeScriptSizes:10=10,7,5<Rev |
| 237 |
This also gives the possibility to have the \cs{normal} size to be |
| 238 |
different from the surrounding pointsize. |
| 239 |
|
| 240 |
\SubSection Typeface definition |
| 241 |
|
| 242 |
Defining a typeface means telling \Lollipop\ how the external font |
| 243 |
name, that is, the name of the \n{tfm} file, is to be constructed from |
| 244 |
the internal parameters. The command \refcs{DefineTypeface} takes four |
| 245 |
parameters and an optional fifth. The parameters are in sequence |
| 246 |
\Enumerate\item The internal name of the typeface: the name that is |
| 247 |
given to the \cs{Typeface} command. |
| 248 |
\item The root of the external file name. It is assumed that all |
| 249 |
font names of different styles and sizes are constructed by appending |
| 250 |
characters to this base. |
| 251 |
\item Suffixes corresponding to the styles that are available. |
| 252 |
\item Suffixes corresponding to the sizes that are available. |
| 253 |
\> |
| 254 |
|
| 255 |
Here is the definition of the Computer Modern typeface: |
| 256 |
|
| 257 |
\Ver> |
| 258 |
\DefineTypeface{ComputerModern}{cm} |
| 259 |
{roman:r; slant:sl; italic:ti; mitalic:mi; bold:bx; typewriter:tt; |
| 260 |
default:r;} |
| 261 |
{<6:5; <7:6; <8:7; <9:8; <10:9; <11:10; |
| 262 |
<12:10 \scaled\magstephalf; |
| 263 |
<14:10 \scaled\magstep1; <16:10 \scaled\magstep2; |
| 264 |
<20:10 \scaled\magstep3; >19:10 \scaled\magstep4; |
| 265 |
default:10;}<Rev |
| 266 |
|
| 267 |
Actually, not all combinations of styles and sizes are available. |
| 268 |
That's where the optional argument comes in. This argument can be |
| 269 |
used to specify with \TeX\ conditionals exceptional style/size |
| 270 |
combinations. Here some trickery is needed: internally the size is |
| 271 |
stored in \cs{Fsize}, and in order to use this parameter we need to |
| 272 |
make the at-sign a letter temporarily. |
| 273 |
|
| 274 |
\Ver>\makeatletter |
| 275 |
\DefineTypeface{Compu ... |
| 276 |
... |
| 277 |
default:10;} |
| 278 |
[\ifStyle:italic \ifnum\Fsize<7 ti7\fi\fi |
| 279 |
\ifStyle:typewriter \ifnum\Fsize<8 tt8\fi\fi]<Rev |
| 280 |
|
| 281 |
You may have noticed that this scheme is not all-powerful. Thus |
| 282 |
I~found it easier to move all Computer Modern sans serif fonts into a |
| 283 |
new typeface: \n{ComputerSans}. |
| 284 |
|
| 285 |
For other typefaces specifying the size suffix may be much easier |
| 286 |
than for Computer Modern. For instance, here is the definition of the |
| 287 |
PostScript Helvetica typeface. |
| 288 |
|
| 289 |
\Ver>\makeatletter |
| 290 |
\DefineTypeface{psHelvetica}{helv} |
| 291 |
{roman:; italic:i; mitalic:i; bold:b; default:;} |
| 292 |
{default: at \Fsize pt;} |
| 293 |
\makeatother<Rev |
| 294 |
|
| 295 |
|
| 296 |
\SubSection Math fonts |
| 297 |
|
| 298 |
Switching styles in math mode should be possible: |
| 299 |
$${\Style:bold x\Style:roman y}z$$ |
| 300 |
|
| 301 |
\SubSection Other font matters |
| 302 |
|
| 303 |
The combination \refcs{SaveFont} with a subsequent |
| 304 |
\refcs{RestoreFont} can |
| 305 |
be used to save and restore the current font. |
| 306 |
|
| 307 |
An abbreviation for a font can be defined by |
| 308 |
\Ver>\DefineFont:name=face,size,style<Rev |
| 309 |
This has the same effect as |
| 310 |
\Ver>\def\name{\TypeFace:face \PointSize:size \Style:style }<Rev |
| 311 |
but it takes considerable less processing inside \TeX. |
| 312 |
|
| 313 |
Even if you don't use Computer Modern as your main typeface, the |
| 314 |
typewriter style is not bad, so a control sequence |
| 315 |
\Ver> |
| 316 |
\def\tt{\Typeface:ComputerModern \Style:typewriter }<Rev |
| 317 |
has been given that makes \refcs{tt} always refer to the |
| 318 |
\n{cmtt} fonts. You're at liberty to change this, of course. |
| 319 |
|
| 320 |
\Section Baselineskip |
| 321 |
|
| 322 |
Corresponding to a font size usually the baseline skip has to change. |
| 323 |
By default a fixed ratio of~$1.2$ for this is taken, for instance |
| 324 |
using a 12~point baseline skip for 10~point fonts. Changing the ratio |
| 325 |
can be done by |
| 326 |
\Ver>\BaselineSkipPointSizeRatio:1.3<Rev |
| 327 |
|
| 328 |
If only for some specific size the baseline skip has to deviate from |
| 329 |
the default ratio, then this can be set by |
| 330 |
\Ver>\SetPointSizeBaselineSkip:9=12<Rev |
| 331 |
|
| 332 |
\Section[sec:indent:control] Indentation Control |
| 333 |
|
| 334 |
\SubSection To indent or not to indent |
| 335 |
|
| 336 |
In most documents there is a general rule that all paragraphs indent |
| 337 |
unless a certain condition, or that they do not indent unless certain |
| 338 |
special conditions hold. For \Lollipop\ documents this is determined |
| 339 |
by the command \refcs{AlwaysIndent}, with values \n{yes}/\n{no}. |
| 340 |
|
| 341 |
To override this default setting a command \refcs{Indent} |
| 342 |
(with values \n{yes}/\n{no}) exists, but that is mostly useful as an |
| 343 |
option in generic constructs, and even there it will not be used much. |
| 344 |
See section~\ref[sec:opt:indent] for options relating to indentation. |
| 345 |
|
| 346 |
Important: never set \cs{parindent} to zero. Preventing indentation |
| 347 |
globally should be done through \ver>\AlwaysIndent:no>. |
| 348 |
|
| 349 |
\SubSection[sec:basic-indent] Basic indent |
| 350 |
|
| 351 |
There is a quantity \refcs{basicindent} that is used on the first |
| 352 |
indentation level (see the next section for an explanation of these |
| 353 |
levels). At the start of a document it is set to the then current |
| 354 |
value of \cs{parindent}. You can override that by |
| 355 |
\refcs{BasicIndentIsSet}: give |
| 356 |
\Ver>\BasicIndentIsSet:no<Rev before the \cs{Start} command. |
| 357 |
|
| 358 |
This way, setting \cs{parindent} in the style definition controls the |
| 359 |
indentation in the whole document. |
| 360 |
|
| 361 |
\SubSection Indentation levels; indentation size |
| 362 |
|
| 363 |
When \Lollipop\ decides that text should be indented, it refers to a |
| 364 |
list of indentations for the exact amount. This list contains |
| 365 |
indentation amounts for each `level' of indentation: initially the |
| 366 |
level is one, and if you nest constructs that indent (for instance |
| 367 |
using a list inside a list) the level goes up one step per nested |
| 368 |
construct. |
| 369 |
|
| 370 |
By |
| 371 |
default the indentation on different levels is a fraction of the |
| 372 |
\cs{basicindent}. Thus you can regulate the indentation on |
| 373 |
all levels simultaneously by resetting the \cs{basicindent}. |
| 374 |
|
| 375 |
\Example |
| 376 |
\Distance:basicindent=15pt |
| 377 |
\DefineList:TestList item:left itemCounter item:stop Stop |
| 378 |
\TestList\item Level one \TestList\item Level two |
| 379 |
\TestList\item Level three\>] |
| 380 |
\Distance:basicindent=25pt |
| 381 |
\TestList\item Level one \TestList\item Level two |
| 382 |
\TestList\item Level three\>] |
| 383 |
\ExampleStop |
| 384 |
|
| 385 |
The amount of |
| 386 |
indentation on a certain level can be set explicitly with |
| 387 |
\refcs{LevelIndent}. |
| 388 |
|
| 389 |
\Example |
| 390 |
\Distance:basicindent=15pt |
| 391 |
\LevelIndent:2=20pt |
| 392 |
\DefineList:TestList item:left itemCounter item:stop Stop |
| 393 |
\TestList\item Level one \TestList\item Level two |
| 394 |
\TestList\item Level three\>] |
| 395 |
\ExampleStop |
| 396 |
|
| 397 |
In fact, sometimes you may want to know the name of the indentation |
| 398 |
on a certain level. This is a control sequence such as |
| 399 |
\refcs{levelindentii} for the second level. You get the idea. |
| 400 |
|
| 401 |
\SubSection Manipulating the indentation level |
| 402 |
|
| 403 |
Every once in a while it can be useful to move to a next indentation |
| 404 |
level, or to return to a previous level. For this |
| 405 |
the two commands \refcs{PushIndentLevel} and \refcs{PopIndentLevel} are |
| 406 |
available. One application is for `interrupted lists': |
| 407 |
|
| 408 |
\Example |
| 409 |
\Itemize\item One |
| 410 |
{\par\PopIndentLevel Interrupted text!\par} |
| 411 |
\item Two\> |
| 412 |
\ExampleStop |
| 413 |
|
| 414 |
See chapter~\ref[chap:external-files] for examples of the use of |
| 415 |
\cs{PushIndentLevel} |
| 416 |
|
| 417 |
\Section Margins |
| 418 |
|
| 419 |
By default, \Lollipop\ tries to keep straight margins. You can change |
| 420 |
its mind about that by \refcs{FlushRight} and \refcs{FlushLeft} |
| 421 |
which are tests: |
| 422 |
\Ver>\FlushRight:no \FlushLeft:no<Rev |
| 423 |
If the margins are not flush, the stretchable white space used |
| 424 |
is \refcs{rightmarginstretch} and \refcs{leftmarginstretch}, |
| 425 |
which can be set by \cs{Distance}. |
| 426 |
|
| 427 |
You have to set the amount of stretch {\it before} specifying that |
| 428 |
the margins will not be flush. The \cs{FlushRight/Left} commands take |
| 429 |
the current value whenever they are called. |
| 430 |
|
| 431 |
\Section White Space |
| 432 |
|
| 433 |
White space can be indicated by \refcs{hwhite} and \refcs{vwhite}. |
| 434 |
They are often useful in style definitions. Use: |
| 435 |
\Ver>\vwhite:15pt<Rev |
| 436 |
or \Ver>\hwhite:{15pt minus 3pt}<Rev |
| 437 |
for stretch and shrink. The command \refcs{white} is independent |
| 438 |
of the mode, and it expands to \cs{hwhite} or \cs{vwhite} |
| 439 |
depending on the prevailing mode of \TeX. |
| 440 |
|
| 441 |
The command \refcs{fillup} is mostly useful in style definitions: |
| 442 |
it tries to fill up as much white space as is possible. |
| 443 |
For instance |
| 444 |
\Ver> line:start litteral:foo fillup litteral:bar line:stop<Rev |
| 445 |
will push \n{foo} and \n{bar} as far apart as is possibly |
| 446 |
within the margins. |
| 447 |
|
| 448 |
\ImpNote |
| 449 |
All three control sequences \cs{white}, \cs{hwhite}, \cs{vwhite} |
| 450 |
have internal equivalents, for instance |
| 451 |
\Ver>\def\white:#1 {\@white{#1}}<Rev |
| 452 |
\ImpNoteStop |
| 453 |
|
| 454 |
\Section[sec:com:distance] Distances |
| 455 |
|
| 456 |
The command \refcs{Distance} can be used |
| 457 |
to declare a name for a certain |
| 458 |
distance, or in more correct \TeX nical lingo, for a certain piece of |
| 459 |
glue. For instance, declaring that |
| 460 |
\Ver>\Distance:oneline=15pt<Rev |
| 461 |
means that you can specify in some constructs |
| 462 |
\Ver>\DefineFoo:Bar whitebefore:oneline whiteafter:oneline<Rev |
| 463 |
If you change your mind later about the value of \n{oneline} you only |
| 464 |
need to change one line in the style definition. |
| 465 |
|
| 466 |
Since the second parameter of \cs{Distance} is bounded by a space (or |
| 467 |
the line end, whatever comes first), you can specify stretchable |
| 468 |
distances by enclosing \n{plus} and \n{minus} parts in braces: |
| 469 |
\Ver>\Distance:oneline={15pt plus 2pt minus 3pt}<Rev |
| 470 |
|
| 471 |
The effect of \cs{Distance} is global. Let me know if you don't |
| 472 |
like it. |
| 473 |
|
| 474 |
\SubSection Distance synonyms |
| 475 |
|
| 476 |
Another use of \cs{Distance} is to define one distance as a synonym |
| 477 |
of another. This may come in handy if you use some basic distance, |
| 478 |
such as \n{oneline} for several purposes. Example: if you specify |
| 479 |
\Ver>\Distance:whitebefore=oneline<Rev |
| 480 |
than the whitespace before a construct will be taken to be |
| 481 |
\n{oneline} if you don't use the \opt{whitebefore} option explicitly. |
| 482 |
|
| 483 |
\SubSection[sec:adapt-distance] Adaptive distances |
| 484 |
|
| 485 |
Suppose you want to declare a section heading as |
| 486 |
\Ver>\DefineHeading:Section ... |
| 487 |
block:start [...] fillupto:widelabel title<Rev |
| 488 |
where \cs{widelabel} is the width of the widest label that |
| 489 |
occurs in your document. This requires just a tad of \TeX\ |
| 490 |
programming. Just copy the details from the example below, which is |
| 491 |
the definition of \cs{Section} in this manual. |
| 492 |
|
| 493 |
By declaring something a \refcs{AdaptiveDistance} instead of just |
| 494 |
\cs{Distance} its value gets written to the \file{.aux} file at the |
| 495 |
end of the run, and restored in the next run. The second argument is |
| 496 |
simply the default value, in case you don't have an auxiliary file |
| 497 |
yet. |
| 498 |
|
| 499 |
\Ver>\AdaptiveDistance:WidestLabel=15pt |
| 500 |
\def\MeasureLabel{\ifdim\BlockWidth>\WidestLabel |
| 501 |
\global\WidestLabel\BlockWidth\fi} |
| 502 |
\DefineHeading:Section |
| 503 |
whitebefore:{20pt plus 2pt} whiteafter:14pt |
| 504 |
line:start PointSize:14 Style:italic |
| 505 |
block:start block:start ChapterCounter . SectionCounter |
| 506 |
Spaces:1 block:stop MeasureLabel |
| 507 |
fillupto:WidestLabel |
| 508 |
title line:stop |
| 509 |
external:contents title external:stop |
| 510 |
label:start ChapterCounter . SectionCounter label:stop |
| 511 |
Stop<Rev |
| 512 |
|
| 513 |
Note how two nested blocks are used: the first is to measure the |
| 514 |
label, and the width is written to the adaptive distance by means of |
| 515 |
a small macro; the second block is to fill out the white space. |
| 516 |
|
| 517 |
If you want the paragraph indentation to depend on this adaptive |
| 518 |
width, you can give |
| 519 |
\Ver>\StartCommand{\Distance:parindent=WidestLabel }<Rev |
| 520 |
to set \cs{parindent} at the start of the document. |
| 521 |
See section~\ref[sec:doc-start-stop] and~\ref[sec:basic-indent]. |
| 522 |
|
| 523 |
\Section[sec:InputFile] Input Files |
| 524 |
|
| 525 |
Parts of a document can be loaded by |
| 526 |
\Ver>\InputFile:parta |
| 527 |
\InputFile:partb<Rev |
| 528 |
et cetera. A~document part loaded by \refcs{InputFile} always starts |
| 529 |
on a new page. In section~\ref[sec:ref-local] it was already |
| 530 |
explained how local references for such files can be created. |
| 531 |
|
| 532 |
Perhaps most importantly, loading files this way provides a form of |
| 533 |
error checking; \Lollipop\ checks at the end of such a file whether all |
| 534 |
used constructs are balanced properly. |
| 535 |
|
| 536 |
|
| 537 |
\Section[sec:tests] Tests |
| 538 |
|
| 539 |
Users can define tests: |
| 540 |
\Ver>\DefineTest:SomethingTheMatter<Rev |
| 541 |
which are set like any other test: |
| 542 |
\Ver>\SomethingTheMatter:yes<Rev |
| 543 |
or \Ver>\SomethingTheMatter:no<Rev |
| 544 |
|
| 545 |
Tests can be used as \Ver>\ifSomethingTheMatter ... \else ... \fi<Rev |
| 546 |
Like any other conditional, test can be used inside constructs. |
| 547 |
\Ver>\DefineFoo:Bar [...] |
| 548 |
ifSomethingTheMatter [...] fi |
| 549 |
[...] Stop<Rev |
| 550 |
|
| 551 |
\Section Goodies |
| 552 |
|
| 553 |
\SubSection List commands |
| 554 |
|
| 555 |
Lollipop does a lot of list processing internally, and a few |
| 556 |
of the commands have been made available to the user. |
| 557 |
|
| 558 |
\Description\item \refcs{NewList} |
| 559 |
creates a list, and sets it to empty: |
| 560 |
\Ver>\NewList:mylist<Rev |
| 561 |
\item \refcs{EmptyList} |
| 562 |
just empty a list. |
| 563 |
\item \refcs{TheList} |
| 564 |
inserts the list. This will typeset the contents of it. |
| 565 |
\Ver>\TheList:mylist<Rev |
| 566 |
\item \refcs{AppendToList} |
| 567 |
adds data to a list. \Ver>\AppendToList:mylist={my data}<Rev |
| 568 |
The data are terminated by a space or line end, hence the braces. |
| 569 |
\> |
| 570 |
|
| 571 |
\SubSection Programming Tools |
| 572 |
|
| 573 |
A few commands are useful for the Lollipop style designer who wants |
| 574 |
to write more sophisticated macros (see for instance the address book |
| 575 |
macros in the last chapter). |
| 576 |
|
| 577 |
\Description\item \refcs{UndefinedCS} |
| 578 |
is a test on control sequences. |
| 579 |
\Ver>\if\UndefinedCS{testcs} ... \else ... \fi<Rev |
| 580 |
\item \refcs{EqualString} |
| 581 |
tests equality of strings. |
| 582 |
\Ver>\if\EqualString{one}{two} ... \else ... \fi<Rev |
| 583 |
\item \refcs{EqualStringX} |
| 584 |
tests equality of strings, using only expansion. |
| 585 |
\Ver>\if\EqualStringX{one}{two} ... \else ... \fi<Rev |
| 586 |
\item \refcs{StringBefore} |
| 587 |
tests lexicographic ordering of strings. The string are not supposed |
| 588 |
to contain characters with char codes~0, 127,~255. |
| 589 |
\Ver>\if\StringBefore{one}{two} ... \else ... \fi<Rev |
| 590 |
\item \refcs{NextChar} |
| 591 |
chooses between two actions, based on the next character. |
| 592 |
\Ver>\if\NextChar[{\macro}{\macro[default]} ...<Rev |
| 593 |
\item \refcs{IsEmptyList} |
| 594 |
can test whether an argument is empty. |
| 595 |
\Ver>\if\IsEmptyList{#1} ...<Rev |
| 596 |
is true for calls such as \ver>\macro{}>. |
| 597 |
\item\refcs{loop} |
| 598 |
can be used for repeated execution of statements. (Users of plaing |
| 599 |
\TeX\ may recognize this macro; it is slightly extended here |
| 600 |
to include the \cs{else} case.) It is |
| 601 |
used as: |
| 602 |
\Ver>\loop ... \if ... \repeat<Rev |
| 603 |
of \Ver>\loop ... \if ... \else ... \repeat<Rev |
| 604 |
|
| 605 |
|
| 606 |
\> |
| 607 |
|
| 608 |
\SubSection[sec:everypar] \cs{everypar} |
| 609 |
|
| 610 |
The \TeX\ primitive \cs{everypar} should not be used any more. |
| 611 |
Instead use the command \refcs{EveryParagraph} as if you are setting |
| 612 |
a token list: |
| 613 |
\Ver>\EveryParagraph{ ... }<Rev |
| 614 |
|
| 615 |
\SubSection[sec:everymath] \cs{everymath} |
| 616 |
|
| 617 |
The \TeX\ primitive \cs{everymath} should not be used any more. |
| 618 |
Instead use the command \refcs{EveryMath} as if you are setting |
| 619 |
a token list: |
| 620 |
\Ver>\EveryMath{ ... }<Rev |
| 621 |
|
| 622 |
\SubSection[sec:everydisplay] \cs{everydisplay} |
| 623 |
|
| 624 |
The \TeX\ primitive \cs{everydisplay} should not be used any more. |
| 625 |
Instead use the command \refcs{EveryDisplay} as if you are setting |
| 626 |
a token list: |
| 627 |
\Ver>\EveryDisplay{ ... }<Rev |
| 628 |
|
| 629 |
\SubSection Allocation |
| 630 |
|
| 631 |
The commands \refcs{SaveAlloc} and subsequent \refcs{RestoreAlloc} save and |
| 632 |
reset the internal \TeX\ allocation counters. |
| 633 |
|
| 634 |
\endinput |
| 635 |
|
| 636 |
% 2014/04/13 Added some notes about \EveryMath, and |
| 637 |
% \EveryDisplay. Also the wrong spelling of `note' changed |
| 638 |
% to `not' in `sec:everypar'. |
| 639 |
% 2014/04/11 Changed \n{tty} style to \n{typewriter} style |
| 640 |
% 92/11/18 Adaptive distances explained |
| 641 |
% 92/11/20 Adaptive counters explained |
| 642 |
% 93/05/13 changes in font macros |