| 1 |
% opt.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 Options |
| 20 |
|
| 21 |
This chapter discusses the various options that are common to all |
| 22 |
\Lollipop\ constructs. |
| 23 |
|
| 24 |
\Section Titles |
| 25 |
|
| 26 |
Any construct can have a title, although of course it is most useful |
| 27 |
for headings. |
| 28 |
A construct has a title if the option \refopt{title} appears. |
| 29 |
Example: |
| 30 |
\Ver> |
| 31 |
\DefineHeading:Section [...] |
| 32 |
Style:bold title |
| 33 |
[...] Stop<Rev |
| 34 |
|
| 35 |
will define a \cs{Section} macro that has a title. |
| 36 |
The macro is then used as |
| 37 |
\Ver> |
| 38 |
\Section The title of this section |
| 39 |
|
| 40 |
Some text in this section.<Rev |
| 41 |
that is, the title is delimited by an empty line. |
| 42 |
|
| 43 |
The title is actually available as a macro \refcs{FooTitle}, so that you |
| 44 |
can write a macro, for instance |
| 45 |
\Ver> |
| 46 |
\def\ComplicatedTitle{ .. \hrule ... |
| 47 |
\vrule ... \vbox \bgroup ... |
| 48 |
\FooTitle ... |
| 49 |
}<Rev |
| 50 |
and use this macro instead of the \opt{title} option |
| 51 |
\Ver>\DefineBar:Foo ... |
| 52 |
ComplicatedTitle |
| 53 |
... Stop<Rev |
| 54 |
However, since the option \opt{title} now doesn't appear anymore, it |
| 55 |
becomes necessary to specify explicitly that there is a title. |
| 56 |
This can be done with the \refopt{HasTitle} option. For instance, |
| 57 |
you define |
| 58 |
\Ver>\DefineBar:Foo ... |
| 59 |
HasTitle |
| 60 |
ComplicatedTitle |
| 61 |
... Stop<Rev |
| 62 |
where \cs{ComplicatedTitle} is a macro that formats the title. |
| 63 |
|
| 64 |
\SubSection Short titles |
| 65 |
|
| 66 |
The option \opt{HasTitle} can have a parameter \n{short}, denoting that |
| 67 |
the title is not delimited by an empty line (or \cs{par}) but by the |
| 68 |
line end. For an example see section~\ref[sec:address]. |
| 69 |
|
| 70 |
\Section[sec:opt:counter] Counters |
| 71 |
|
| 72 |
There are three ways for Lollipop to figure out that a generic |
| 73 |
construct has a counter. First of all, in |
| 74 |
\Ver>\DefineFoo:Bar [...] |
| 75 |
BarCounter [...]<Rev |
| 76 |
the \cs{BarCounter} will be defined automatically. |
| 77 |
|
| 78 |
Additionally there is the option \refopt{counter}, which can be used |
| 79 |
to declare the representation of the option, for instance |
| 80 |
\opt{counter:i} allocated a counter that is printed in lowercase roman |
| 81 |
numerals. For the available representations, |
| 82 |
see~\ref[sec:counter:repr]. |
| 83 |
|
| 84 |
Finally, if the counter is only used in a macro, the |
| 85 |
option \refopt{HasCounter} will cause the counter to be created anyhow. |
| 86 |
This is analogous to the \opt{HasTitle} option. |
| 87 |
|
| 88 |
\SubSection Counter synonyms |
| 89 |
|
| 90 |
Every once in a while you may want different constructs to use the same |
| 91 |
counter. For instance, if your book has definitions, theorems, lemmas, |
| 92 |
corollaries and notations, it may confuse the reader if they all have |
| 93 |
their own counter. The numbering would seem to jump all over the place. |
| 94 |
|
| 95 |
A `counter synonym' can be declared in \Lollipop\ by a slight abuse of |
| 96 |
the \opt{counter} option. |
| 97 |
\Example |
| 98 |
\DefineTextBlock:Theorem counter:1 begingroup Style:bold |
| 99 |
literal:Theorem Spaces:1 TheoremCounter Spaces:2 endgroup |
| 100 |
text Stop |
| 101 |
\DefineTextBlock:Corollary counter:Theorem begingroup Style:italic |
| 102 |
literal:Corollary Spaces:1 CorollaryCounter Spaces:2 endgroup |
| 103 |
text Stop |
| 104 |
\DefineTextBlock:Definition counter:Theorem begingroup Style:roman |
| 105 |
literal:Definition Spaces:1 DefinitionCounter Spaces:2 endgroup |
| 106 |
text Stop |
| 107 |
\Definition We define a {\it Foo} to be an arbitrary object\> |
| 108 |
\Theorem Foos have arbitrary properties\> |
| 109 |
\Corollary Foos are extremely valuable\> |
| 110 |
\Corollary Foos are extremely worthless\> |
| 111 |
\Theorem Foos don't exist\> |
| 112 |
\ExampleStop |
| 113 |
|
| 114 |
You can only declare a counter to be synonym for something that has |
| 115 |
already been created. In the above example you cannot define the |
| 116 |
\cs{Theorem} after the \cs{Corollary}. |
| 117 |
|
| 118 |
\ImpNote |
| 119 |
At the start of defining the construct, \cs{BarCounter} is defined to |
| 120 |
be an option: |
| 121 |
\Ver>\add@generic@default{\has@counterno |
| 122 |
\def\counter@repr{1} |
| 123 |
\csarg\def{\gen@option@name{\@name Counter}}{% |
| 124 |
\@add@toks{\@name Counter}\global\has@counteryes}}<Rev |
| 125 |
|
| 126 |
Then, |
| 127 |
\Ver>\add@generic@stop@default{\ifhas@counter |
| 128 |
\xp\expandafter\xp\install@counter |
| 129 |
\xp\counter@repr\@space\fi}<Rev |
| 130 |
|
| 131 |
|
| 132 |
The counter is stepped, and the new value is stored in a mark item, |
| 133 |
in \cs{outer@start@commands}: |
| 134 |
|
| 135 |
\Ver> |
| 136 |
\ifhas@counter |
| 137 |
\nxp\StepCounter:\expandafter\@name\@space |
| 138 |
% This sets the \current@label by default |
| 139 |
\ifhas@marks \edef\nxp\cs@e |
| 140 |
{\nxp\nxp\nxp\refresh@mark@item |
| 141 |
{\@name Counter}{\CSname{\@name Counter}}}% |
| 142 |
\nxp\cs@e |
| 143 |
\fi |
| 144 |
\fi<Rev |
| 145 |
\ImpNoteStop |
| 146 |
|
| 147 |
\Section Chunks of text |
| 148 |
|
| 149 |
Especially in headings, short chunks of text may need a special |
| 150 |
treatment. For instance, the number may have to be filled to a certain |
| 151 |
width, or a line may have to be drawn of the exact length of the |
| 152 |
title. Lollipop have various general options (so they can also be used |
| 153 |
in other contexts than headings) for handling pieces of text. |
| 154 |
|
| 155 |
\SubSection[sec:opt:block] The \opt{block} option\label[opt:block] |
| 156 |
|
| 157 |
The \refopt{block} option takes up a piece of text and fits it on one |
| 158 |
line. It can measure the text, or set the size. Also there are a number |
| 159 |
of ways of placing a block. |
| 160 |
|
| 161 |
Basic usage: |
| 162 |
\Ver> block:start [...] block:stop<Rev |
| 163 |
This takes the enclosed text, and reproduces it. This is mostly |
| 164 |
interesting in combination with \opt{textcolumn}, |
| 165 |
see~\ref[sec:opt:textcolumn]. |
| 166 |
\Ver> block:hang [...] block:stop<Rev |
| 167 |
The resulting block is dropped until its top touches the baseline. |
| 168 |
For uniformity of appearance, the resulting width of the block can be |
| 169 |
specified: |
| 170 |
\Ver> block:start [...] fillupto:20pt<Rev |
| 171 |
The name of a \cs{Distance} parameter can be used here. |
| 172 |
|
| 173 |
\Example |
| 174 |
\DefineHeading:TestHeading |
| 175 |
line:start block:hang PointSize:8 SetFont |
| 176 |
TestHeadingCounter fillupto:20pt |
| 177 |
block:hang PointSize:14 SetFont title block:stop |
| 178 |
line:stop Stop |
| 179 |
\TestHeading Top Aligning the Title |
| 180 |
|
| 181 |
\endExample |
| 182 |
|
| 183 |
The block is usually in between the margins of the text, but it can be |
| 184 |
made to stick out into the margin, by closing it with the option |
| 185 |
\refopt{stickout}. For the left margin this done as |
| 186 |
\Ver> block:start [...] stickout:left<Rev |
| 187 |
and for the right margin |
| 188 |
\Ver> block:start [...] stickout:right<Rev |
| 189 |
The size of the box can be specified, for instance as |
| 190 |
\Ver> block:start [...] stickout:left=20pt<Rev |
| 191 |
For a left box the material in it is pushed to the left edge, for a |
| 192 |
right sticking box it is shifted to the right. |
| 193 |
|
| 194 |
\SubSection[sec:blockwidth] Block Measuring |
| 195 |
|
| 196 |
All blocks are immediately measured when they are placed. This makes it |
| 197 |
possible for instance to underline a title exactly. After a block has |
| 198 |
been placed, its width is available as \refcs{BlockWidth}. |
| 199 |
\Example |
| 200 |
\def\rulespecs{height 1pt width \BlockWidth\relax} |
| 201 |
\DefineHeading:TestHeading Style:bold |
| 202 |
line:start block:start TestHeadingCounter . Spaces:2 stickout:left |
| 203 |
block:start title block:stop line:stop |
| 204 |
vwhite:2pt hrule rulespecs vwhite:10pt Stop |
| 205 |
\TestHeading The Title Is Underlined |
| 206 |
|
| 207 |
The text follows. |
| 208 |
\ExampleStop |
| 209 |
Observe how a control sequence \cs{rulespecs} is used to sneak the |
| 210 |
height and width of the rule into the definition. This is necessary |
| 211 |
because control sequences are not allowed in a construct definition. |
| 212 |
|
| 213 |
\SubSection[sec:opt:line] The \opt{line} option |
| 214 |
|
| 215 |
The option \refopt{line} is used to create a single strip of text that |
| 216 |
fits exactly in between the margins of the page. Most of the time, titles |
| 217 |
will be in a line. |
| 218 |
|
| 219 |
\Example |
| 220 |
\DefineHeading:TestHeading |
| 221 |
line:start block:start TestHeadingCounter Spaces:1.5 stickout:left |
| 222 |
title line:stop Stop |
| 223 |
\TestHeading A Title |
| 224 |
|
| 225 |
\endExample |
| 226 |
|
| 227 |
Another example was above. Here is another use of a line: |
| 228 |
|
| 229 |
\Example |
| 230 |
\DefineHeading:TestHeading |
| 231 |
line:start TestHeadingCounter fillup title line:stop Stop |
| 232 |
\TestHeading The title |
| 233 |
|
| 234 |
\endExample |
| 235 |
|
| 236 |
\SubSection[sec:opt:textcolumn] The \opt{textcolumn} option |
| 237 |
|
| 238 |
In the examples above all titles fit on one line comfortably. If this |
| 239 |
is not the case, the title can be put in a \refopt{textcolumn} which can |
| 240 |
span several lines. |
| 241 |
|
| 242 |
\Example |
| 243 |
\DefineHeading:TestHeading |
| 244 |
line:start block:start TestHeadingCounter Spaces:2 block:stop |
| 245 |
textcolumn:topline title textcolumn:stop |
| 246 |
line:stop Stop |
| 247 |
\TestHeading A very very very very very very very very very very very |
| 248 |
very very very very very very very very very very very very very |
| 249 |
very very very very very very very very long title |
| 250 |
|
| 251 |
\endExample |
| 252 |
|
| 253 |
This option is mostly interesting in combination with others such as |
| 254 |
\opt{block} and \opt{line}. As is apparent from the above example: a |
| 255 |
block placed in the same line as a text column will detract from the |
| 256 |
latter's width. |
| 257 |
|
| 258 |
(In fact it is the other way around: \Lollipop\ sets |
| 259 |
the line with a text column of width zero to determine the remaining |
| 260 |
space. Then the line is set again. This may give problems if you |
| 261 |
manipulate parameters inside the line, because the line is in effect |
| 262 |
typeset twice. Also make sure not to have other \cs{vbox}-es in the |
| 263 |
line than the text column.) |
| 264 |
|
| 265 |
\SubSection[sec:opt:traps] Traps |
| 266 |
|
| 267 |
It is a bad idea to have material in headings and such that is not |
| 268 |
inside a block, textcolumn, or line. For instance: |
| 269 |
|
| 270 |
\Example |
| 271 |
\DefineHeading:TestHeading |
| 272 |
block:start TestHeadingCounter Spaces:2 block:stop |
| 273 |
title Stop |
| 274 |
\TestHeading Where does the title go? |
| 275 |
|
| 276 |
\endExample |
| 277 |
|
| 278 |
\Section[sec:opt:label] Labels |
| 279 |
|
| 280 |
References to any counter will always be correct, no matter if that |
| 281 |
counter has changed after retypesetting the document, if symbolic |
| 282 |
references are used. Referencing is explained in detail in |
| 283 |
chapter~\ref[chap:referencing]. |
| 284 |
|
| 285 |
The way a symbolic reference is formatted can be altered from the |
| 286 |
default (just give the counter) by using the \refopt{label} option. |
| 287 |
\Ver>\DefineHeading:TestSection |
| 288 |
line:start Style:italic TestSectionCounter Spaces:2 title line:stop |
| 289 |
label:start ( TestSectionCounter ) label:stop Stop<Rev |
| 290 |
See further section~\ref[sec:shape:reference]. |
| 291 |
|
| 292 |
|
| 293 |
\Section[sec:opt:penalties] Break before / after |
| 294 |
|
| 295 |
The options \refopt{breakbefore} and \refopt{breakafter} control how |
| 296 |
eager \TeX\ will be to break the page before or after a construct. These |
| 297 |
options take one value, a so-called `penalty' value, meaning that the |
| 298 |
higher the value you specify, the higher the penalty is, and |
| 299 |
therefore the less likely it is that the page will be broken there. |
| 300 |
|
| 301 |
Numerical values are typically in the tens or hundreds; any value |
| 302 |
of \n{10$\,$000} or more means that there will never be a break at |
| 303 |
that point; a value of \n{-10$\,$000} or less means a guaranteed |
| 304 |
break. If you don't want to remember these rules, values of \n{yes} |
| 305 |
and \n{no} mean a guaranteed break, and no break respectively. |
| 306 |
|
| 307 |
\WizNote |
| 308 |
A further exceptional value is \n{breakbefore/after:0}, this will |
| 309 |
cause no penalty to be placed. The reason for this is highly \TeX |
| 310 |
nical. |
| 311 |
\> |
| 312 |
|
| 313 |
\Section[sec:opt:indent] Indentation |
| 314 |
|
| 315 |
The option \refopt{indentafter} controls the behaviour of the first |
| 316 |
paragraph after a generic construct., \refopt{indentinside}, |
| 317 |
\refopt{indentfirst}. |
| 318 |
|
| 319 |
\Section Rules |
| 320 |
|
| 321 |
There is an option \refopt{hrule}. You should not write |
| 322 |
\Ver>\def\rulemacro{\hrule height [...] } |
| 323 |
\DefineHeading [...] rulemacro [...] Stop<Rev |
| 324 |
because then \Lollipop\ cannot prevent page breaks around the rule. |
| 325 |
Instead write |
| 326 |
\Ver>\def\rulespecs{ height [...] } |
| 327 |
\DefineHeading [...] hrule rulespecs [...] Stop<Rev |
| 328 |
so that the option \opt{hrule} is used. See |
| 329 |
section~\ref[sec:blockwidth] for an example. |
| 330 |
|
| 331 |
\Section Embedded constructs |
| 332 |
|
| 333 |
Most generic constructs will be vertically separated from the |
| 334 |
surrounding text. However, in rare cases (and for unusual applications) |
| 335 |
it be desired to have a construct that is part of a paragraph. For this |
| 336 |
the option \refopt{embedded} exists. |
| 337 |
|
| 338 |
This option has the following values. |
| 339 |
\Ver> embedded:no<Rev |
| 340 |
This is the default. |
| 341 |
\Ver> embedded:left<Rev |
| 342 |
The construct continues an already started paragraph, but after the |
| 343 |
construct a vertical break follows. |
| 344 |
\Ver> embedded:right<Rev |
| 345 |
After the construct a paragraph can continue, but the construct is |
| 346 |
separated vertically from preceding text. |
| 347 |
\Ver> embedded:yes<Rev |
| 348 |
The construct is both left and right embedded. |
| 349 |
|
| 350 |
Embedding a construct has an interesting application to generating |
| 351 |
indexes. (See chapter~\ref[chap:external-files] for general information |
| 352 |
about external files.) This can be done by having embedded headings |
| 353 |
that write their title to the index file. |
| 354 |
|
| 355 |
\Example |
| 356 |
\DefineExternalFile:tIndex=tix |
| 357 |
\DefineHeading:NewWord embedded:yes |
| 358 |
block:start Style:bold title block:stop |
| 359 |
external:tIndex title external:stop Stop |
| 360 |
\def\introword#1{\NewWord #1\par} |
| 361 |
In this sentence two \introword{flubrious} words are |
| 362 |
\introword{stinselsed}. |
| 363 |
\ExampleStop |
| 364 |
|
| 365 |
Cute, ain't it? |
| 366 |
|
| 367 |
A word of warning though. Headings and such generate \TeX\ `marks' |
| 368 |
which take up main memory. You only need these if you are going |
| 369 |
to be referring to that object with \cs{LastPlaced} or such; see |
| 370 |
section~\ref[sec:head/foot]. Embedded headings used as above |
| 371 |
usually don't need these marks, so you can prevent \TeX\ overflow by |
| 372 |
putting the option \opt{nomarks} in their definition. |
| 373 |
|
| 374 |
\Section Obscure options |
| 375 |
|
| 376 |
\SubSection Arguments |
| 377 |
|
| 378 |
In case you want to interface to other macro packages, you may want to |
| 379 |
let a construct generate a call to the other package. For this, the |
| 380 |
\Lollipop\ macro should be able to produce sequences such as |
| 381 |
\ver>\begin{itemize}>. The problem here is the braces. The option |
| 382 |
\refcs{arg} produces a braced expression. |
| 383 |
|
| 384 |
For instance |
| 385 |
\Ver>\DefineTextBlock:LaTeXlist begin arg:{itemize} text |
| 386 |
end arg:{itemize} Stop<Rev |
| 387 |
makes it possible to use call \LaTeX\ macros from \Lollipop. |
| 388 |
|
| 389 |
\SubSection[sec:implicit:close] Implicit closing |
| 390 |
|
| 391 |
The control sequence \refcs{>} closes the current group, and \refcs{>]} |
| 392 |
closes all currently open groups. Every once in a while this is too |
| 393 |
drastic. Hence there is an option \refopt{noimplicitclose} that can be |
| 394 |
used to prevent a construct from being closed implicitly. Using \cs{>]} |
| 395 |
inside such a construct will close all enclosed constructs. |
| 396 |
|
| 397 |
See the definition of \cs{EExample} in this manual for an example. |
| 398 |
|
| 399 |
\Section[sec:opt:test] Testing |
| 400 |
|
| 401 |
There is an option \opt{test}. |
| 402 |
|
| 403 |
\endinput |
| 404 |
|
| 405 |
% 92/11/10 \BlockWidth discussed in 'block' section |
| 406 |
% 92/11/15 counter:othercounter discussed |
| 407 |
% 92/11/21 option 'arg' |
| 408 |
|