Professional Documents
Culture Documents
Boxes PDF
Boxes PDF
Nelson H. F. Beebe
University of Utah
Department of Mathematics, 110 LCB
155 S 1400 E RM 233
Salt Lake City, UT 84112-0090
USA
Email: beebe@math.utah.edu, beebe@acm.org,
beebe@computer.org
WWW URL: http://www.math.utah.edu/~beebe
Telephone: +1 801 581 5254
FAX: +1 801 581 4148
28 March 2009
Abstract
This document shows how to position text in boxes in TEX and LATEX,
and provides a convenient set of commands for doing so simply.
1 Introduction
TEX and LATEX are powerful systems for typesetting and document markup,
but that power often means considerable complexity. Both have lots of com-
mands that help to hide the low-level details. However, a major challenge
in typesetting most technical documents is to identify additional operations
that are commonly needed for that particular document. One can then de-
fine private commands that strip the details entirely away, leaving just the
name of the operation, and the text that it consumes. The input job is then
much easier, and the input file is much more readable, especially if care is
taken in its preparation to use consistent spacing and logical indentation,
and to keep lines relatively short. It can otherwise be rather painful to find
a missing or mismatched brace that TEX complains about in a line that is
thousands of characters long.
It is important to remember that, as a document author, you are likely
to spend much more time looking at the TEX input than at its nicely typeset
output, so readable input should matter to you. If you do your typesetting
job well, your readers will benefit, even it they might not be aware that
1
2 BOXES AND GLUE IN TEX 2
they have. They will certainly notice, however, if your output looks like the
trashy regurgitation of a word processor on a typical desktop computer.
TEX and LATEX are capable of producing beautifully typeset and easy-
to-read documents, but they cannot do so without the help of document
authors and document style designers.
The next section of this document provides some of the low-level details
of how TEX handles the typesetting process. If you find it complex, do not
be alarmed. The whole point is to learn how to conceal the messy details
inside easy-to-use commands, and once those commands have been worked
out, everyone can use them without thought of their underpinnings. The
section after that deals with the same problem, but at a logically-higher
level, where we build similar new commands with less trouble.
\showthe \dimen1
> 72.26999pt.
2 BOXES AND GLUE IN TEX 4
\dimen2 = 10pc
\showthe \dimen2
> 120.0pt.
\dimen3 = 10cc
\showthe \dimen3
> 128.40103pt.
Notice that TEX’s output is always in points, showing that it converts dif-
ferent input units to a common system of measurement.
You can convert a dimension to the much-smaller units of scaled points
by assigning it to another kind of TEX register designed to hold signed inte-
gers, the \count0 through \count255 registers:
\dimen4 = 0.5pt
\count4 = \dimen4
\showthe \count4
> 32768.
You might have noticed that the conversion from inches to points was not
quite what we claimed in the summary of TEX units. Here is how to see the
differences:
\dimen1 = 1in
\dimen2 = 72.27pt
\count1 = \dimen1
\count2 = \dimen2
\showthe \count1
> 4736286.
\showthe \count2
> 4736287.
The two values differ by the tiny value 1 sp, so we can in practice ignore
that difference. If we use higher-precision arithmetic, we find the exact
decimal equivalents of the fractions as
TEX actually uses that last relation as the definition of the conversion of
inches to scaled points, so that our assignment of 1 in to \dimen1 has to
be rounded to the nearest integral number of scaled points. That is why
in the round-trip conversion from decimal to binary and back to decimal,
2 BOXES AND GLUE IN TEX 5
1 in became 72.26999 pt. TEX guarantees that its output decimal numbers
are always converted on input back to the original binary numbers from
whence they came. For more on the story of TEX’s I/O conversions, see [3].
\showthe \dimen1
16383.99998pt.
\showthe \count1
1073741823.
\dimen4 = \dimen2
\advance \dimen4 by \dimen4 % form (largest + largest)
-16386.00002pt.
A similar experiment carried out the 36-bit PDP-10 shows the same be-
havior up to the assignment to \dimen6, but since there are actually four
more bits available for the integer part, we get this instead:
*\showthe \dimen5
> 81915.99998pt.
We then repeat the addition 31 more times, and finally we have a problem:
\advance \dimen5 by 16383pt \showthe \dimen5 % try 30
524256.99998pt.
TEX continues the additions until five extra bits have been used (36−32 = 4
bits, plus one overflow bit), and then the arithmetic system used by the na-
tive Pascal compiler traps a real integer overflow, and pauses the program
at the operating-system prompt. We then continue it, and find a negative
value from the overflow of addition into the sign bit.
This is 7 pt type.
This is 10 pt type.
This is 12 pt type.
This is 14 pt type.
This is 18 pt type.
This is 24 pt type.
Many type faces designed since the computer age have the same letter
shapes in all type sizes, but readability is improved if the shapes are varied.
Compare these examples:
New Century Schoolbook at 5 pt
The four sample glue settings store, respectively, fixed glue, stretchable
glue, shrinkable glue, and flexible glue that can both stretch and shrink,
but only up to a specified amount. Interword and intersentence spaces are
generally defined with glue like this, so that if more stretch or shrink of
2 BOXES AND GLUE IN TEX 8
spaces is needed than is available, TEX can warn about lines of text that
are underfull (too little text to fill the line), or overfull (too much text in the
line).
Although overfull lines are reported in the TEX log file, they can be hard
to find in the typeset document if they only stick out a little. To make
them highly visible while you are fine tuning your final document, assign
the variable \overfullrule a nonzero dimension, such as 10 cm. TEX then
displays a solid black box, called a rule, of that width in the right margin
on each line that is overfull. To make the rules disappear, simply remove,
or comment out, the assignment, or reset its value to 0 pt.
Just as you can assign dimension registers to count registers to convert
from points to scaled points, you can assign skip registers to dimension and
count registers to discard the flexible parts:
\skip1 = 10pt plus 3pt minus 2pt
\showthe \skip1
> 10.0pt plus 3.0pt minus 2.0pt.
\dimen1 = \skip1
\showthe \dimen1
> 10.0pt.
\count1 = \skip1
\showthe \count1
> 655360.
The first two look identical, because TEX typesets the word, and then makes
a 40pt-wide box from it. However, in the first case, there is not enough
material to fill that box, so TEX complains that something is wrong:
Underfull \hbox (badness 10000) detected at line 169
This is not an error, but merely warns the user that the typeset output may
not be optimal. The badness value reported is part of the mathematical
algorithm that TEX uses for line and page breaking, but we do not consider
it further in this document.
Supplying the trailing \hfil glue in the second example makes TEX
happy, because the flexible glue allows the box to be filled exactly.
There is yet another kind of glue that can both stretch and shrink by
an ‘infinite’ amount: \hss (horizontal infinitely shrinkable and stretchable
glue), and its companion for vertical mode, \vss. Here is why this doubly-
flexible glue is useful. Suppose you want to put an object in a box, but you
do not know in advance whether the box is big enough, and you do not care
whether or not it is. TEX complains about overfull boxes if there is too much
text, but is silent if there is doubly-flexible glue involved:
|\hbox to 10pt{word}| |word
|
|\hbox to 10pt{word \hss}| |word
|
|\hbox to 10pt{\hss word}| word|
|
|\hbox to 10pt{\hss word\hss}| w
| ord
|
In the first case, TEX warns
Overfull \hbox (12.95982pt too wide) detected at line 201
The right-overlap macro makes its argument stick out to the right of the
current point, whereas its left-overlap companion makes the argument pro-
trude to the left. Here is an example:
stuff|comes from \llap{stuff}|, while |\rlap{~extra} is typeset
away from this text as |.extra
Notice that the sentence-ending period overlaps the space pre-
ceding the last word, and that the first word sticks out in the left
margin of this indented display.
If no width is given for the horizontal box, then TEX creates a box of
exactly the right size to hold its contents. Fill glue then disappears entirely:
2 BOXES AND GLUE IN TEX 10
\def \W {word}
|\W \W| |wordword|
|\W \hfil \W| |wordword|
|\hfil \W \hfil \W| |wordword|
|\hfil \W \hfil \W \hfil| |wordword|
|\hfil \W \hfil \W \hfil| |wordword|
There is no space between the words, even though we used a space after the
\W shorthands, because of TEX’s rule that spaces are ignored after macros
whose names are one or more letters. TEX’s official name for these is control
words.
TEX also has macros that consist of a backslash and a single special
character, such as \%. They are called control sequences, and TEX does not
ignore spaces after them.
If we add fixed-width boxes to our last example, the fill glue takes effect
again:
|\hbox to 60pt{\W \W}| |wordword |
|\hbox to 60pt{\W \hfil \W}| |word word|
|\hbox to 60pt{\hfil \W \hfil \W}| | word word|
|\hbox to 60pt{\hfil \W \hfil \W \hfil}| | word word |
|\hbox to 60pt{\hfil \W \hfil \W \hfil}| | word word |
We can make a few experiments with the two-ell forms of glue like this:
|\hbox to 60pt{\hfil \W \hfill}| |word |
|\hbox to 60pt{\hfill \W \hfil}| | word|
|\hbox to 60pt{\hfill \W \hfill}| | word |
Clearly, two-ell glue overwhelms one-ell glue. This can be useful in the
design of complex macros for positioning of text in boxes.
that design choice in the New Century Schoolbook typeface used in this
document: ( h g ) [ k j ] { l p }.
You can force TEX to choose a larger height and depth than normal when
you write a command for a horizontal box by ensuring that it has suitable
contents, such as an invisible vertical rule of zero width. The command
\hbox to 50pt {\vrule height 20pt depth 10pt width 0pt \it stuff}
produces a box whose (invisible) outline looks like this: stuff . The
three extents of the vertical rule can appear in any order, and any conve-
nient units.
In order to see the otherwise-invisible box edges in that example, we
used the LATEX built-in command \fbox to create a frame, and we eliminated
the default margin inside the frame by setting \fboxsep = 0pt. Plain TEX
does not have the \fbox command, but The TEXbook shows how to make
something like it on pp. 223 and 321.
One particular zero-width vertical rule is convenient for ensuring that
separate boxes all get the same height and depth. It has the height and
depth of parentheses in the normal prose font, and is given the macro name
\strut. Its definition in the plain.tex file of macro definitions is roughly
equivalent to this:
\def \strut {\vrule height 8.5pt depth 3.5pt width 0pt}
Compare these two experiments with outlined boxes, first without struts,
and then with struts:
\def \Fbox #1{\fbox{\strut #1}}
\fbox{aeou} \fbox{dhkl} \fbox{gpq} aeou dhkl gpq
\Fbox{aeou} \Fbox{dhkl} \Fbox{gpq} aeou dhkl gpq
Notice the different vertical extents of the boxes in the first case, and how
they have identical extents in the second case.
produces one two threefour. As the example shows, we can put spaces
between them, or run them together so that they fit tightly.
2 BOXES AND GLUE IN TEX 12
one-ell \hfil on the lines of text inside the vertical box would actually
be set centered, rather than set flush left. The two-ell \hfill over-
whelms the one-ell form, and forces text flush left. We show examples
of both of these.
left text
center text
right text
left text
\vbox{\fbox{one}}
\vbox{\fbox{two}}
\vbox{\fbox{three}}
\vbox{\fbox{four}}\vbox{\fbox{five}}\vbox{\fbox{six}}
produces one
two
three
four five
The first four boxes are indented according to the current value of \parindent.
The sixth box disappeared off the edge of the page, because it was given no
preceding space at which the line could be broken.
If we put those boxes inside a vertical box, inside of which we set the
horizontal size, then we can control the line width:
\vbox
{%
\hsize = 40pt
\parindent = 0pt
\vbox{one}
\vbox{two}
\vbox{three}
\vbox{four}\vbox{five}\vbox{six}%
}
one
two
three
four
five
produces six . The input spacing between the vertical boxes has no
visible effect.
There is some additional vertical spacing in that last display that we
can reveal by framing the contents of the inner horizontal boxes, so that
the input
\vbox
{%
\hsize = 40pt
\parindent = 0pt
\vbox{\fbox{one}}
\vbox{\fbox{two}}
\vbox{\fbox{three}}
\vbox{\fbox{four}}\vbox{\fbox{five}}\vbox{\fbox{six}}%
}
2 BOXES AND GLUE IN TEX 16
one
two
three
four
five
produces six , and again, the input spacing does not matter.
We can eliminate the extra vertical spacing with \offinterlineskip to
get tight vertical stacking with the input
\vbox
{%
\offinterlineskip
\hsize = 40pt
\parindent = 0pt
\vbox{\fbox{one}}
\vbox{\fbox{two}}
\vbox{\fbox{three}}
\vbox{\fbox{four}}\vbox{\fbox{five}}\vbox{\fbox{six}}%
}
one
two
three
four
five
to produce six .
If we instead fit the vertical boxes inside a horizontal box, with the input
\hbox
{%
\hsize = 30pt
\parindent = 0pt
\vbox{\fbox{one}}
\vbox{\fbox{two}}
\vbox{\fbox{three}}
\vbox{\fbox{four}}\vbox{\fbox{five}}\vbox{\fbox{six}}%
}
then we get output like this: one two three four five six , where
the vertical boxes are each 30 pt wide.
As a final example, we stack some text inside the vertical boxes using
TEX’s \cr command to force line breaks. Since this document is written in
LATEX markup, we have to restore the definition of that macro inside the
outer box. The input
\hbox
{%
\let \cr = \\
\hsize = 30pt
\parindent = 0pt
2 BOXES AND GLUE IN TEX 17
{%
\parindent = 0pt
\hsize = #1
\vbox to #2
{%
\hfil \strut #3%
\vfill
\hfil \strut #4%
}%
}%
}
Youcanmakeitevenlessreadablebydroppingdocumentationandspacing, like
this:
\def\Rbox#1#2#3#4{\hbox to#1{\parindent=0pt\hsize=#1\vbox to#2{%
2 BOXES AND GLUE IN TEX 19
\hfill\strut#3\vfill\hfill\strut#4}}}
Sadly, far too many TEX macro-definition files, and LATEX style files, look
like that already. The low-level details of typesetting are hard, and it is
simply foolish to make them even harder with inscrutable code. Humans
are unlikely to notice the microseconds of computer time saved by eliminat-
ing spaces in macro files.
The input for the rest of this paragraph looks like this:
Here is how the boxes can be used inside a paragraph as if
they were single words:
\fbox{\Lbox{20pt}{20pt}{TL}{BL}}
\fbox{\Cbox{20pt}{20pt}{TC}{BC}}
\fbox{\Rbox{20pt}{20pt}{TR}{BR}}
\fbox{\Lbox{20pt}{20pt}{TL}{}}
\fbox{\Cbox{20pt}{20pt}{TC}{}}
\fbox{\Rbox{20pt}{20pt}{TR}{}}
\fbox{\Lbox{20pt}{20pt}{}{BL}}
\fbox{\Cbox{20pt}{20pt}{}{BC}}
\fbox{\Rbox{20pt}{20pt}{}{BR}}.
Here is how the boxes can be used inside a paragraph as if they were single
TL TC TR TL TC TR
words: BL BC BR BL BC BR. These boxes have a
depth below the baseline because we defined them with a \strut.
\vcenter to #2
{%
\strut #3%
\vfil
\strut #4%
}%
$%
}%
}
\def \LTbox #1#2#3#4%
{% left-adjusted text in \vtop box
\hbox to #1
{%
\parindent = 0pt
\hsize = #1
\vtop to #2
{%
\strut #3%
\vfil
\strut #4%
}%
}%
}
Here is how they can be used inside a paragraph as if they were single
TL TC TR TL TC TR
words: , with more text fol-
BL BC BR BL BC BR
lowing.
Now change Cbox to Tbox and repeat that example. Here is how they
can be used inside a paragraph as if they were single words: TL TC TR
BL BC BR
2 BOXES AND GLUE IN TEX 21
LC
\LBCbox{30pt}{20pt}{LC} ,
CC
\CBCbox{30pt}{20pt}{CC} , and
RC
\RBCbox{30pt}{20pt}{RC} .
The \vtop-based macros produce text like this:
\LTCbox{30pt}{20pt}{LTC} ,
LTC
\CTCbox{30pt}{20pt}{CTC} , and
CTC
\RTCbox{30pt}{20pt}{RTC} .
RTC
Notice that they hang below the baseline: the reason is that the contents
of the vertical box start with fill glue, so TEX pretends that there is an
invisible object of zero depth and height above the glue, and that object’s
baseline determines the top alignment.
The \vcenter-based macros produce text like this:
2 BOXES AND GLUE IN TEX 22
\LCCbox{30pt}{20pt}{LCC} LCC ,
\RCCbox{30pt}{20pt}{RCC} RCC .
In all of the vertical box examples so far, the text arguments have been
short enough to fit on one line, and the horizontal fills handled the position-
ing. What happens if they need multiple lines? The fills then apply to just
the first and last lines, and we get peculiar text alignment. Thus, the input
\fbox{\LCCbox{120pt}{80pt}{\it Long text...}}
and
\fbox{\CCCbox{120pt}{80pt}{\it Long text...}}
than normal (as we do near the end of this document), or set it in a smaller
type size, or break it into multiple tables. Manual rearrangement of such
material may help, but sometimes, you have to rewrite the nearby prose,
making it slightly longer or shorter to get things to fit. There are also low-
level commands described in Chapter 15 of The TEXbook that allow you to
tweak the line-breaking algorithm without changing the prose when your
material almost, but not quite, fits a page.
A negative first argument lowers the box. Here are some examples:
upper
A \raisebox{10pt}{\fbox{upper}} A
A \raisebox{-10pt}{\fbox{lower}} A
lower
upper
A \fbox{\raisebox{10pt}[25pt]{\fbox{upper}}} A
A \fbox{\raisebox{-10pt}[25pt]{\fbox{lower}}} A
lower
upper
A \fbox{\raisebox{10pt}[25pt][15pt]{\fbox{upper}}} A
A \fbox{\raisebox{-10pt}[25pt][15pt]{\fbox{lower}}} A
lower
For longer strings of text, LATEX provides the paragraph box, which is
defined like this: \parbox[position]{width}{contents}. The optional po-
sition is a letter b for alignment of the bottom line with the current baseline,
or t for alignment of the top line with the surrounding baseline. Without
3 BOXES AND GLUE IN LATEX 26
that argument, the box is centered vertically around the prevailing base-
line. The box can be used as if it were a letter or a word, so we can put it in
the middle of a sentence. The input
This is text \parbox{30pt}{\it and this is boxed text} and
this is more text.
produces
and this
is boxed
text with b
This is text alignment and this is more text.
and this
is boxed
text with b
This is text alignment and this is more text.
and this is
boxed text
with b
This is text alignment and this is more text.
and this is
boxed text
with b
This is text alignment and this is more text.
The positioning works just like that for \parbox, with alignment letters b
and t, and if they are omitted, a default of vertical centering.
In particular, verbatim text produced with the \verb command is illegal
in macro arguments, so it cannot be used with \fbox, \framebox, \makebox,
\mbox, or \parbox, but it can be used inside a minipage. The input
\begin{minipage}{170pt}
This is inline verbatim \verb=\verb|\%{}|=, and this
is a verbatim display:
%
\begin{verbatim}
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello, world\n");
exit (EXIT_SUCCESS);
}
\end{verbatim}
\end{minipage}
3 BOXES AND GLUE IN LATEX 28
\RequirePackage[dvips]{color}
\RequirePackage{varioref} % for \vref and \vpageref
\newcommand{\figlabel}[1]{\label{fig:#1}}
3 BOXES AND GLUE IN LATEX 29
Table 1: Wide table set with p-style column formatting in the LATEX tabular
environment.
Book Description Publisher
The TEXbook [2] a book about high-quality typesetting, particularly for Addison–Wesley
mathematical and technical material
The Advanced a book that takes the reader into the depths of TEX; it has Springer-Verlag
TEXbook [7] particularly thorough treatment of the subject of TEX
output routines, a topic that receives relatively little
attention in The TEXbook
Table 2: Wide table set with l-style column formatting in the LATEX tabular
environment. Each cell of data is set with a \parbox command, without a
positioning argument, so that the cell paragraph is centered vertically.
The TEXbook [2] a book about high-quality typesetting, particularly for Addison–Wesley
mathematical and technical material
a book that takes the reader into the depths of TEX; it has
The Advanced particularly thorough treatment of the subject of TEX
Springer-Verlag
TEXbook [7] output routines, a topic that receives relatively little
attention in The TEXbook
LATEX: A
Document
Preparation
a book about a document-independent logical markup
System: User’s Addison–Wesley
system that is built on top of the TEX typesetting system
Guide and
Reference
Manual [4, 5]
The LATEX a book that covers some of the most important LATEX
Companion packages for color, font selection, graphics, and specialized Addison–Wesley
[1, 6] typesetting
3 BOXES AND GLUE IN LATEX 30
\newcommand{\figref}[1]{Figure~\ref{fig:#1}
\vpageref{fig:#1}\markref{figure}}
\newcommand{\shortfigref}[1]{Figure~\ref{fig:#1}\markref{figure}}
\newcommand{\markref}[1]{%
\marginpar{\fcolorbox{black}{yellow}%
{\small \bfseries #1 xref}}%
}
\renewcommand{\markref}[1]{}
Some documents need more kinds of floats than just the figures and ta-
bles that LATEX provides by defaults. For example, a book about computer
programming is likely to have many sample programs that could usefully
be displayed as program floats. The LATEX \newfloat command is the key
to defining a new class of floats, but it takes a bit more work than might be
expected from its documentation. Here is an example from a book on pro-
gramming whose private style file gives each program float a background
color and an index entry:
\RequirePackage[dvips]{color}
\RequirePackage{coloralias} % for indirect color names
\RequirePackage{rgb} % for color names
\definecoloralias{programcolor}{azure}
%%% Define a private float style that allows us to control where the
%%% caption goes, and what font is used in the caption name and
%%% number:
\newcommand{\fs@pgmplaintop}
{%
\fs@plain % we share much of the setup of plain
\def \@fs@mid {\vspace\belowcaptionskip\relax}%
\let \@fs@iftopcapt = \iftrue
%% We want other floats to have bold names and numbers too; the
%% default in plaintop puts them in rmfamily (float.sty:143).
3 BOXES AND GLUE IN LATEX 31
\renewcommand{\floatc@plain}[2]
{%
{% group to restrict color change
\color{textcolor}%
\setbox \@tempboxa = \hbox{{\@fs@cfont #1:} #2}%
\ifdim \wd \@tempboxa > \hsize
{\@fs@cfont #1:} #2\par
\else
\hbox to \hsize {\hfil \box \@tempboxa \hfil}%
\fi
\smallskip % extra space below caption
}%
}
\floatstyle{pgmplaintop}
%%% Programs are a new float object, and create a \jobname.lop file
%%% that is read and typeset in the front matter. The float name
%%% "Program" is reused in the front matter, and in the captions, so
%%% it cannot be arbitrary.
\newfloat{Program}{htb!p}{lop}[chapter]
\noindent
\index{program box}%
\colorbox{programcolor}{\parbox{0.983\textwidth}{#2}}%
\end{small}
\vrule width \textwidth height 0.2ex
\par
\end{Program}%
}
\fbox{%
\setlength{\unitlength}{1pt}%
\begin{picture}(100,30)(0,0)
\put( 0, 0){LL text}
\put(100, 0){\makebox[0pt][r]{LR text}}
\put(100, 30){\makebox[0pt][r]{UR text}}
\put( 0, 30){UL text}
\end{picture}%
}
UL text UR text
produces the output LL text LR text , but the labels are not quite
where we want them. We therefore adjust their coordinates slightly, and
retry with
\fbox{%
\setlength{\unitlength}{1pt}%
\begin{picture}(100,30)(0,0)
\put( 0, 0){LL text}
\put(100, 0){\makebox[0pt][r]{LR text}}
\put(100, 23){\makebox[0pt][r]{UR text}}
\put( 0, 23){UL text}
\end{picture}%
}
UL text UR text
UL text UR text
CTR
to produce this output: LL text LR text .
Our final macros properly handle scaling, as these experiments with
\unitlength set to 0.75 pt, 1 pt, and 1.25 pt, respectively, show:
UL text UR text
UL text UR text
UL text UR text CTR
CTR
CTR
LL text LR text , LL text LR text , and LL text LR text .
We can use them to position arbitrary nested text as well. The input
\newcommand{\samplebox}{%
\fbox{%
\setlength{\unitlength}{0.75pt}%
\begin{picture}(80,40)(0,0)
\put( 0, 0){\LLBox{LL}}
\put(80, 0){\LRBox{LR}}
\put(40 20){\CCBox{CTR}}
\put( 0,40){\ULBox{UL}}
\put(80,40){\URBox{UR}}
\end{picture}%
}%
}
\fbox{%
\setlength{\unitlength}{2.5pt}%
\begin{picture}(80,40)(0,0)
\put( 0, 0){\LLBox{\samplebox}}
\put(80, 0){\LRBox{\samplebox}}
\put(40,20){\CCBox{\samplebox}}
\put( 0,40){\ULBox{\samplebox}}
\put(80,40){\URBox{\samplebox}}
\end{picture}%
}
UL UR UL UR
CTR CTR
LL LR LL LR
UL UR
CTR
LL LR
UL UR UL UR
CTR CTR
produces this output: LL LR LL LR
We can do similar displays with mathematical material. The input
\fbox
REFERENCES 35
{%
\setlength{\unitlength}{2pt}%
\begin{picture}(120,40)(0,0)
\put( 0, 0)
{\LLBox{$\displaystyle e = \prod_{n=1}^{100}\sin(n)$}}
\put(120, 0){\LRBox{$\displaystyle f(x) = \left \{
\begin{array}{ll}
g & \quad \textrm{if $x < 0$}\\
h & \quad \textrm{if $x = 0$}\\
i & \quad \textrm{if $x > 0$}
\end{array}
\right . $}}}
\put( 60,20){\CCBox{$\bullet$}}
\put( 0,40){\ULBox{$a = b + c$}}
\put(120,40)
{\URBox{$\displaystyle d = \sum_{n=1}^{\infty}n^{-2}$}}
\end{picture}%
}%
a=b+c ∞
X
d= n−2
n=1
•
Y
100 g if x < 0
e= sin(n) f (x) = h if x = 0
produces this output: n=1 i if x > 0
Plain TEX does not have an analogue of the LATEX picture environment,
but page 389 of The TEXbook sketches how one might get started on its
design.
References
[1] Michel Goossens, Frank Mittelbach, and Alexander Samarin. The LATEX
Companion. Tools and Techniques for Computer Typesetting. Addison-
Wesley, Reading, MA, USA, 1994.
[2] Donald E. Knuth. The TEXbook. Addison-Wesley, Reading, MA, USA,
1984.
[3] Donald E. Knuth. A simple program whose proof isn’t. In W. H. J. Fei-
jen, A. J. M. van Gasteren, D. Gries, and J. Misra, editors, Beauty is our
business: a birthday salute to Edsger W. Dijkstra, chapter 27, pages
233–242. Springer-Verlag, Berlin, Germany / Heidelberg, Germany /
London, UK / etc., 1990. This paper discusses the algorithm used in
TEX for converting between decimal and scaled fixed-point binary val-
ues, and for guaranteeing a minimum number of digits in the decimal
representation.
REFERENCES 36