Line boxes
5.9.1 Line boxes
The \text command provides a line box that typesets its argument without line breaks. As a result, you may find the argument extending into the margin. The resulting box is
handled by L A TEX as if it were a single large character. For instance,
\text{database} causes L A TEX to treat the eight characters of the word database as if they were one.
This technique has a number of uses. It prevents L A TEX from braking the argument (see Section 5.4.9). It also allows you to use the phrase in the argument in a formula (see Section 7.4.6).
The argument of \text is typeset in a size appropriate for its use, for example, as
a subscript or superscript. See Section 7.4.6 for an example.
Line boxes—a refinement The \mbox command is the short form of the \makebox command. Both \mbox and
\text prevent breaking the argument, but \mbox does not change size in subscripts and superscripts.
The full form of the \makebox command is \makebox[width ][alignment ]{text } where the arguments are
width, the (optional) width of the box. If [width ] is omitted, the box is as wide as necessary to enclose its contents.
alignment, (optionally) one of c (the default), l, r, or s. The text is centered by default, l sets the argument flush left, r right, and s stretches the text the full length of the box if there is blank space in the argument.
text, the text in the box.
A width argument can be specified in inches (in), centimeters (cm), points (pt), or relative units such as em or ex (see Sections 5.8.3 and 15.5.2).
108 Chapter 5 Typing text
The following examples, \makebox{Short title.}End\\
\makebox[2in][l]{Short title.}End\\ \makebox[2in]{Short title.}End\\ \makebox[2in][r]{Short title.}End\\ \makebox[2in][s]{Short title.}End
typeset as
Short title.End Short title.
End
Short title.
End Short title.End
Short
title.End
The optional width argument, width, can use four length commands: \height \depth \totalheight and \width These are the dimensions of the box that would be produced without the optional width
argument. Here is a simple example. The command
\makebox{hello} makes a box of width \width. To typeset hello in a box three times the width, that
is, in a box of width 3\width, use the command \makebox[3\width]{hello} So start\makebox[3\width]{hello}end typesets as
start hello
end
The formal definition of these four length commands is the following: \height is the height of the box above the baseline \depth is the depth of the box below the baseline \totalheight is the sum of \height and \depth \width is the width of the box
5.9 Boxes 109
There is an interesting variant of the \makebox command. The \rlap command makes a box and pretends that it is of width zero. For instance,
\newcommand{\circwithdot} {\mathbin{\rlap{$\mspace{2mu}\cdot$}\hbox{$\circ$}}}
defines the command \circwithdot, so you can type $f\circwithdot\varphi$
which prints as f ·◦ ϕ. There is also an \llap command.