| 1 |
% border.doc --- version 1.0 (21 October 1991) |
| 2 |
% This is the documentation for border.tex. |
| 3 |
% To read this file, process it with (plain) TeX: tex border.doc |
| 4 |
% (To do that, you need both border.tex and manmac.tex. The latter has |
| 5 |
% the macros for typesetting the TeXbook, as explained in appendix E. |
| 6 |
% It comes free with the standard distribution of TeX.) |
| 7 |
% |
| 8 |
% NOTE: Processing this file with TeX will create empty files |
| 9 |
% index.tex and answers.tex in your directory. And if you |
| 10 |
% have a file pages.tex in your directory, TeX will probably |
| 11 |
% get very confused. |
| 12 |
% The manmac format will try to load a font called cmman; if |
| 13 |
% TeX complains that it cannot find that font you can savely |
| 14 |
% ignore that, since the font is not actually used. |
| 15 |
% |
| 16 |
% This file: copyright (c) 1991 Marcel van der Goot. |
| 17 |
% You may redistribute this file and printed versions of it. |
| 18 |
% |
| 19 |
% original: csvax.cs.caltech.edu [131.215.131.131] in pub/tex |
| 20 |
% (use anonymous ftp). Also in various archives. |
| 21 |
% |
| 22 |
% Marcel van der Goot |
| 23 |
% [email protected] |
| 24 |
% Caltech 256--80 |
| 25 |
% Pasadena, CA 91125 |
| 26 |
% (818) 356--4603 |
| 27 |
|
| 28 |
% ------ definitions for manual pages: |
| 29 |
% The documentation is typeset using Knuth's ``manmac'' macros, with a |
| 30 |
% few additional things defined here. You are free to use or adapt these |
| 31 |
% extra definitions. |
| 32 |
|
| 33 |
\input manmac % the macros used for typesetting The TeXbook (appendix E) |
| 34 |
\catcode`^=7 % manmac makes ^ active for creating an index |
| 35 |
% we don't make an index, and we need ^ to be non-active |
| 36 |
|
| 37 |
{\catcode`\^^M=12 \endlinechar=-1 % 12 = other |
| 38 |
\long\gdef\manpagehead#1^^M#2^^M#3^^M^^M% tex-file, description, version |
| 39 |
{\egroup % matches \bgroup in \manpage |
| 40 |
\par\vfill\eject |
| 41 |
\edef\rhead{\manualname: #1\unskip}% |
| 42 |
\setbox1=\hbox{\titlefont #1\quad}% |
| 43 |
\setbox3=\vtop{\advance\hsize by-\wd1 \parindent=0pt \raggedright |
| 44 |
#2\par |
| 45 |
#3\par |
| 46 |
\cnotice |
| 47 |
}% |
| 48 |
\line{\box1\box3}% |
| 49 |
\bigskip\bigskip\bigskip\noindent |
| 50 |
}% |
| 51 |
} % restore \catcode`\^^M |
| 52 |
|
| 53 |
\outer\def\manpage |
| 54 |
{\bgroup\catcode`\^^M=12 |
| 55 |
\manpagehead |
| 56 |
} |
| 57 |
|
| 58 |
\hsize=6.5in\vsize=8.9in % default plain TeX values |
| 59 |
\pagewidth=\hsize \pageheight=\vsize |
| 60 |
|
| 61 |
\def\cnotice{Copyright \copyright\ 1991 Marcel R. van der Goot} |
| 62 |
\def\manualname{Midnight Macros} |
| 63 |
|
| 64 |
% LaTeX logo, from latex.tex (except for the capital `A': manmac |
| 65 |
% doesn't have a real smallcaps font) |
| 66 |
\def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\sc A}\kern-.15em |
| 67 |
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} |
| 68 |
|
| 69 |
\tenpoint |
| 70 |
|
| 71 |
% (end of extra definitions) |
| 72 |
|
| 73 |
% -------------------- border.doc: |
| 74 |
|
| 75 |
\input Midnight/border % change this to refer to border.tex on your system |
| 76 |
|
| 77 |
\def\boxelm#1% |
| 78 |
{\hbox{\vrule width .2mm |
| 79 |
\vbox to 10mm{\hrule height.2mm |
| 80 |
\hbox to9.8mm{}\vfil |
| 81 |
\hrule height.2mm}% |
| 82 |
\vrule width .2mm |
| 83 |
}} |
| 84 |
|
| 85 |
\def\bulletelm#1% |
| 86 |
{\ifcase#1% |
| 87 |
\roundcorners0% |
| 88 |
\or\hbox to1cm{\hss$\bullet$\hss}% |
| 89 |
\or\roundcorners2% |
| 90 |
\fi |
| 91 |
} |
| 92 |
|
| 93 |
\def\cloudelm#1% |
| 94 |
{\hbox{\roundcorners0\roundcorners2}} |
| 95 |
|
| 96 |
\def\numberelm#1% |
| 97 |
{\vbox to12pt{\vss |
| 98 |
\hbox to12pt{\hss\number#1\hss} |
| 99 |
\vss |
| 100 |
}} |
| 101 |
|
| 102 |
\pageno=17 % follows styledef.doc |
| 103 |
|
| 104 |
\manpage border.tex |
| 105 |
Macros to typeset borders. |
| 106 |
Version: 1.0 (21 October 1991) (doc: 23 Oct 1991) |
| 107 |
|
| 108 |
\setborder[\hsize,1em,\smallskipamount]\border{\noindent |
| 109 |
The macros described in this manual section are used to typeset borders, |
| 110 |
such as the border around this paragraph. These borders are built from |
| 111 |
different ``characters'': in this example from quarter circles for the corners |
| 112 |
and straight line segments for the edges, but, given an appropriate font, |
| 113 |
other borders can also be typeset. (Below we explain how a border |
| 114 |
font must be designed in order to be useful with these macros.) Before |
| 115 |
any of the macros described below can be used, you must |\input| |
| 116 |
border.tex.* |
| 117 |
} |
| 118 |
|
| 119 |
There\footnote{}{* Border.tex also works with \LaTeX.} |
| 120 |
% if the \footnote is done within \setborder, it gets lost |
| 121 |
are several ways of typesetting borders, depending on the characters |
| 122 |
that form the border. Macros such as |\border| |
| 123 |
create a vbox of specified height and width (the depth is always zero), |
| 124 |
containing only the border. Typesetting text within a border is done by |
| 125 |
creating a box with the text and superimposing it on the box with the border, |
| 126 |
as explained later. The types of border we will now describe differ in the |
| 127 |
way they compose characters to build a border; the choice of the characters |
| 128 |
is determined by another macro (|\borderelm|). The border around the |
| 129 |
previous paragraph was typeset with |\border|. It is built from eight |
| 130 |
different characters: `\roundcorners0', `\roundcorners1', and |
| 131 |
`\roundcorners2' for the top; `\roundcorners3' and `\roundcorners4' for the |
| 132 |
center; and `\roundcorners5', `\roundcorners6', and `\roundcorners7' for the |
| 133 |
bottom. |\border| takes two arguments, the height and the width of the border. |
| 134 |
\begintt |
| 135 |
\border{2cm}{10cm} |
| 136 |
\endtt |
| 137 |
creates a border like this: |
| 138 |
$$\border{2cm}{10cm}$$ |
| 139 |
It is a vbox with height $2$ cm, depth $0$, and width $10$ cm. |
| 140 |
|
| 141 |
In order to create a border of the exact specified dimensions, some characters |
| 142 |
may need to overlap. Suppose we built a border from the following character, |
| 143 |
a $1$ cm by $1$ cm box: |
| 144 |
$$\boxelm0$$ |
| 145 |
The following is the |
| 146 |
border created by |\border{4.8cm}{10.5cm}|: |
| 147 |
$$ |
| 148 |
\let\borderelm=\boxelm |
| 149 |
\border{4.8cm}{10.5cm} |
| 150 |
$$ |
| 151 |
As you see, some of the boxes overlap, in order to get the specified |
| 152 |
dimensions. This overlap is always between the edge elements, there is never |
| 153 |
overlap with the corner elements (unless the size is too small). |
| 154 |
In fact, the overlap is always with |
| 155 |
the edge elements that are closest to the corners. (|\border| always sets |
| 156 |
at least one edge element for each edge.) |
| 157 |
|
| 158 |
|\border| works fine if the edge elements can overlap, which basically |
| 159 |
restricts them to be ``rule like.'' There is an alternative to |\border|, |
| 160 |
called |\xborder|. It is used in the same way as |\border|, but the exact |
| 161 |
size is obtained by putting extra space |
| 162 |
between the elements, rather than overlapping them. Suppose we build a |
| 163 |
border with the |
| 164 |
same corner elements as before, but with the edge built from ``bullets'' |
| 165 |
rather than straight line segments. The top element consists of a bullet |
| 166 |
centered in a $1$ cm wide box. Here are the top lines obtained from |
| 167 |
|\border{...}{4.5cm}| and |\xborder{...}{4.5cm}|, respectively. |
| 168 |
\let\borderelm=\bulletelm |
| 169 |
$$ |
| 170 |
\line{\hss\hborder{4.5cm}012\qquad\qquad\hxborder{4.5cm}012\hss} |
| 171 |
$$ |
| 172 |
In case of |\xborder|, the proper vertical size is also obtained by spacing. |
| 173 |
|
| 174 |
Some border characters, however, need to abut in order to form |
| 175 |
a border. For instance, suppose we want to make a ``cloud like'' border, |
| 176 |
where the top corners and top edge elements are all `\cloudelm0' |
| 177 |
In this case, |\border{...}{1.6cm}| and |\xborder{...}{1.8cm}| give |
| 178 |
\let\borderelm=\cloudelm |
| 179 |
$$\line{\hss |
| 180 |
\hborder{1.6cm}012\qquad and\qquad\hxborder{1.8cm}012% |
| 181 |
\hss}$$ |
| 182 |
Clearly, neither solution works very well. |
| 183 |
For this case there are two other macros, |\minusborder| and |\plusborder|. |
| 184 |
They take the same arguments as |\border|, but produce a box of rounded |
| 185 |
dimensions rather than of the exact size. The border is built by abutting |
| 186 |
the elements. |\minusborder| rounds the size down, whereas |\plusborder| rounds |
| 187 |
the size up. |\minusborder{...}{1.8cm}| and |\plusborder{...}{1.8cm}| give |
| 188 |
$$\line{\hss |
| 189 |
\hminusborder{1.8cm}012\qquad and\qquad\hplusborder{1.8cm}012% |
| 190 |
\hss}$$ |
| 191 |
|
| 192 |
\setbox0=\hbox{\it width}\setbox2=\hbox{\it hspace}\setbox4=\hbox{\it vspace} |
| 193 |
|
| 194 |
The above macros all generate empty borders. Typically, one wants to put some |
| 195 |
text in the border. There is one macro to make that easy, |\setborder|. It |
| 196 |
is called as follows: |
| 197 |
\begintt |
| 198 |
\setborder[|copy0, |copy2, |copy4]\border{ ... } |
| 199 |
\endtt |
| 200 |
where the |...| stands for the text that must be boxed. In this case, |\border| |
| 201 |
will be used to create the border, but you can also use |\xborder| etc. |
| 202 |
The border will be \copy0\ wide (or a rounded value); the height of the |
| 203 |
border is determined by the amount of text. The text itself is first |
| 204 |
broken in paragraphs and lines, as usual in \TeX. The width of the lines |
| 205 |
is $\copy0 - 2\cdot\copy2$. The text is than put in the border with |
| 206 |
\copy4\ space at the top and at the bottom, and \copy2\ space at the left and |
| 207 |
at the right hand sides. |
| 208 |
For instance, the first paragraph of this manual section was set with |
| 209 |
\begintt |
| 210 |
\setborder[\hsize,1em,\smallskipamount]\border |
| 211 |
{\noindent The macros described ... |
| 212 |
.... |
| 213 |
} |
| 214 |
\endtt |
| 215 |
The \copy0\ and \copy2\ must be dimensions; \copy4\ can be a dimension or |
| 216 |
a glue amount (without |\vskip|). |
| 217 |
|
| 218 |
\danger With |\setborder|, the text between braces, |{...}|, is read |
| 219 |
in the same way as when you write |\vbox {...}|. (You can use |\bgroup| and |
| 220 |
|\egroup| instead of the braces.) The text is {\it not\/} an argument of |
| 221 |
|\setborder|, which is important if it contains catcode changes. You can |
| 222 |
change the paragraph shape, or have more than one paragraph of text. |
| 223 |
\let\borderelm=\roundcorners |
| 224 |
$$\setborder[10cm, 1cm, 4mm]\border{ |
| 225 |
\parindent=0pt \parfillskip=0pt |
| 226 |
\leftskip=0pt plus 1cm minus 5mm |
| 227 |
\rightskip=0pt plus 1cm minus 5mm |
| 228 |
For instance, the text in this paragraph is set with some extra |\leftskip| |
| 229 |
and |\rightskip| glue, which takes care of centering every line. This |
| 230 |
was done as follows: |
| 231 |
} |
| 232 |
$$ |
| 233 |
\beginlines |
| 234 |
|\setborder[10cm, 1cm, 4mm]\border{| |
| 235 |
|\parindent=0pt \parfillskip=0pt| |
| 236 |
|\leftskip=0pt plus 1cm minus 5mm \rightskip=0pt plus 1cm minus 5mm| |
| 237 |
\goodbreak |
| 238 |
|For instance, the text in this paragraph ...| |
| 239 |
|...| |
| 240 |
\nobreak |
| 241 |
|}| |
| 242 |
\endlines |
| 243 |
|
| 244 |
\danger If |\setborder| does not suit your purpose, you can write your |
| 245 |
own equivalent. Generally, to put text in a border, you first generate |
| 246 |
a box containing the border of the appropriate size. Then you make a box |
| 247 |
containing this border box plus the text superimposed on it. Superimposing |
| 248 |
is done by either ``backspacing'' using negative kerns, or by making a |
| 249 |
zero width or height border box, in a similar way as |\llap| makes a zero |
| 250 |
width box. Usually, you have to use several nested levels of boxing to |
| 251 |
get the desired result. |
| 252 |
|
| 253 |
We have described the different ways of composing border characters, but not |
| 254 |
yet how to specify which characters are used. Whenever a border is typeset, |
| 255 |
it is assumed that a macro |\borderelm#1| exists. This macro is called with |
| 256 |
as argument a number in the range $0,\dots,7$; it should return the appropriate |
| 257 |
border element, where the elements are numbered as follows: |
| 258 |
\let\borderelm=\numberelm |
| 259 |
$$\minusborder{2cm}{5cm}$$ |
| 260 |
|\borderelm| is called within an hbox; it should typeset a character, a |
| 261 |
box, or an vrule. (Since the macro is expanded within an hbox, you should be |
| 262 |
careful not to put extra spaces in it; doing that may cause strange |
| 263 |
gaps in the border.) |
| 264 |
|
| 265 |
A convenient way of writing |\borderelm| is with |
| 266 |
an |\ifcase| construction. For instance, assume that in font |\qc| the |
| 267 |
characters |a|, |b|, |c|, etc. correspond to `\roundcorners0', |
| 268 |
`\roundcorners1', `\roundcorners2', etc. Then you could write |\borderelm| |
| 269 |
as follows: |
| 270 |
\beginlines |
| 271 |
|\def\borderelm#1%| |
| 272 |
\nobreak |
| 273 |
| {{\qc \ifcase#1| |
| 274 |
| a\or b\or c\or d\or e\or f\or g\or h% no extra space| |
| 275 |
| \fi| |
| 276 |
| }}| |
| 277 |
\endlines |
| 278 |
In fact, a macro like this is already defined in border.tex. It is called |
| 279 |
|\roundcorners|, so that you can say |\let\borderelm=\roundcorners| to |
| 280 |
get the borders with rounded corners. The corner elements come from |
| 281 |
font |\manfnt|, which corresponds to the external font `manfnt.' (The |
| 282 |
corner elements are described on page 389 of The \TeX book.) |\roundcorners| |
| 283 |
scales, which means that you can say, for instance, |
| 284 |
\begintt |
| 285 |
\font\manfnt=manfnt scaled 2074 |
| 286 |
\endtt |
| 287 |
to get larger corners --- provided you have the appropriately scaled |
| 288 |
font file (2074 corresponds to |\magstep4|). |
| 289 |
If you do not want to load the manfnt font (e.g., because your installation |
| 290 |
does not have it), you should define |\let\manfnt=\relax| before you |
| 291 |
|\input| border.tex. |
| 292 |
|
| 293 |
Hopefully a variety of border fonts will come available in the future. But even |
| 294 |
with just the quarter circles you can already vary your borders quite a bit. |
| 295 |
We already saw a border with half circles before, it is an easy exercise |
| 296 |
to define a complete border that way. The following definition defines |
| 297 |
a fancier corner: |
| 298 |
\beginlines |
| 299 |
|\setbox0=\hbox{\roundcorners2}| |
| 300 |
|\vbox{\offinterlineskip| |
| 301 |
| \hbox{\copy0\roundcorners0\copy0}| |
| 302 |
| \hbox to 3\wd0{\hfil\roundcorners7}| |
| 303 |
| \hbox to 3\wd0{\hfil\copy0}| |
| 304 |
\nobreak |
| 305 |
| }%| |
| 306 |
\endlines |
| 307 |
It defines the ``number 2'' (or number 5) corner: |
| 308 |
\setbox0=\hbox{\roundcorners2} |
| 309 |
\vbox{\offinterlineskip |
| 310 |
\hbox{\copy0\roundcorners0\copy0} |
| 311 |
\hbox to 3\wd0{\hfil\roundcorners7} |
| 312 |
\hbox to 3\wd0{\hfil\copy0} |
| 313 |
} ; |
| 314 |
the other corners can be defined similarly. |
| 315 |
|
| 316 |
\danger If you want, you can omit the corners from |\borderelm| (i.e., write |
| 317 |
|\borderelm| to return nothing for arguments $0$, $2$, $5$, and $7$). |
| 318 |
But if you do not want any edge elements, you should still put something |
| 319 |
with width (or height) for the top/bottom (or left/right) edges; for instance, |
| 320 |
|\hbox to10pt{}| is a valid top element. Border.tex uses several box and |
| 321 |
dimen registers. Rather than reserving private registers, which would |
| 322 |
make them unavailable for other purposes, border.tex uses |\box0|, |\box2|, |
| 323 |
|\box4|, |\dimen0|, |\dimen2|, and |\count2|. Normally, this does not cause |
| 324 |
problems, since they are always restored to their old value. The only time |
| 325 |
you should take this into account, is in |\borderelm|: this macro should |
| 326 |
not depend on any global values of these registers, nor should it make |
| 327 |
any lasting changes to them. |
| 328 |
|
| 329 |
\danger If you are a font designer, and want to define a font that can be |
| 330 |
used with border.tex, you should understand something of how |\border| etc. |
| 331 |
build the borders. A border is built from three horizontal strips. The top |
| 332 |
and bottom strips consist of a corner element, a number of edge elements, |
| 333 |
and another corner element. These elements are aligned by their baselines, |
| 334 |
and the width of the border(-strip) is determined by the width of the |
| 335 |
bounding boxes. Therefore, the ``ink'' in the border elements |
| 336 |
should be close to the outside edges of the bounding boxes; otherwise there |
| 337 |
will not be a proper relation between the actual size of the border and |
| 338 |
the size of the visible border. The center strip is built from an edge, |
| 339 |
white space (glue), and another edge. The amount of white space is chosen |
| 340 |
so that the width of the center strip is the width of the top strip. |
| 341 |
The whole border is built by vertically aligning the top strip, a |
| 342 |
number of center strips, and the bottom strip. This is done by aligning |
| 343 |
the left hand edges of the horizontal strips. The vertical size of the |
| 344 |
border is again determined by the vertical size of the bounding boxes. |
| 345 |
You may notice that the quarter circle elements described on p. 389 of The |
| 346 |
\TeX book (used in |\roundcorners|), do not fit properly in their bounding |
| 347 |
boxes for the purpose of setting borders. In fact, |\roundcorners| must go |
| 348 |
to considerable effort to reposition the bounding boxes. If you can, avoid |
| 349 |
such problems with any new fonts you design. |
| 350 |
|
| 351 |
There are two more variants of borders. First, to set only one horizontal |
| 352 |
strip of a border generated by |\border|, you can use |\hborder|. It takes |
| 353 |
four argument: the width, and the numbers of the left element, middle |
| 354 |
element, and right element. E.g., |\border{4cm}012| generates the top |
| 355 |
of the border, whereas |\border{4cm}567| generates the bottom. There |
| 356 |
are also |\hxborder|, |\hminusborder|, and |\hplusborder|. However, there |
| 357 |
are no vertical equivalents. |
| 358 |
|
| 359 |
Finally, there are macros |\minusgray| and |\plusgray|. They behave |
| 360 |
like their border counterparts, except that the center of the border |
| 361 |
is filled with an extra character (|\borderelm8|) rather than with white space. |
| 362 |
For use with these macros, |\borderelm| must return characters as follows: |
| 363 |
\let\borderelm=\numberelm |
| 364 |
$$\minusgray{2cm}{5cm}$$ |
| 365 |
This is useful if you have characters that contain a ``gray'' pattern |
| 366 |
(a ``stipple'' or ``Ben Day'' pattern). Although a font with a gray pattern |
| 367 |
should not be hard to define, to the author's knowledge there is currently |
| 368 |
no such font in the public domain. These gray macros can also be used with |
| 369 |
|\setborder|. |
| 370 |
|
| 371 |
\bye |
| 372 |
|