Next: Measuring things Up: Commands Previous: Definitions

## Boxes

These next three commands for making LR-boxes all existed in LATEX 2.09. They have been enhanced in two ways.

`\makebox` `[`<width>`]` `[`<pos>`]` `{`<text>`}`
`\framebox` `[`<width>`]` `[`<pos>`]` `{`<text>`}`
`\savebox` `{`<cmd>`}` `[`<width>`]` `[`<pos>`]` `{`<text>`}`

One small but far-reaching change for LATEX2e is that, within the <width> argument only, four special lengths can be used. These are all dimensions of the box that would be produced by using simply `\mbox``{`<text>`}`:

  `\height`its height above the baseline;
  `\depth`its depth below the baseline;
  `\totalheight`the sum of `\height` and `\depth`;
  `\width`its width.

Thus, to put `hello' in the centre of a box of twice its natural width, you would use:

       \makebox[2\width]{hello}

Or you could put f into a square box, like this:

       \framebox{\makebox[\totalheight]{\itshape f\/}}

Note that it is the total width of the framed box, including the frame, which is set to `\totalheight`.

The other change is a new possibility for <pos>: `s` has been added to `l` and `r`. If <pos> is `s` then the text is stretched the full length of the box, making use of any `rubber lengths' (including any inter-word spaces) in the contents of the box. If no such `rubber length' is present, an `underfull box' will probably be produced.

`\parbox` `[`<pos>`]` `[`<height>`]` `[`<inner-pos>`]` `{`<width>`}` `{`<text>`}`
`\begin{minipage}` `[`<pos>`]` `[`<height>`]` `[`<inner-pos>`]` `{`<width>`}`
<text>
`\end{minipage}`

As for the box commands above, `\height`, `\width`, etc. may be used in the `[`<height>`]` argument to denote the natural dimensions of the box.

The <inner-pos> argument is new in LATEX2e. It is the vertical equivalent to the <pos> argument for `\makebox`, etc, determining the position of <text> within the box. The <inner-pos> may be any one of `t`, `b`, `c`, or `s`, denoting top, bottom, centered, or `stretched' alignment respectively. When the <inner-pos> argument is not specified, LATEX gives it same value as <pos> (this could be the latter's default value).

`\begin{lrbox}` `{`<cmd>`}`
<text>
`\end{lrbox}`

This is an environment which does not directly print anything. Its effect is to save the typeset <text> in the bin <cmd>. Thus it is like `\sbox` `{`<cmd>`}` `{`<text>`}`, except that any white space before or after the contents <text> is ignored.

This is very useful as it enables both the `\verb` command and the `verbatim` environment to be used within <text>.

It also makes it possible to define, for example, a `framed box' environment. This is done by first using this environment to save some text in a bin <cmd> and then calling `\fbox{\usebox{`<cmd>`}}`.

The following example defines an environment, called `fmpage`, that is a framed version of `minipage`.

       \newsavebox{\fmbox}
       \newenvironment{fmpage}[1]
         {\begin{lrbox}{\fmbox}\begin{minipage}{#1}}
         {\end{minipage}\end{lrbox}\fbox{\usebox{\fmbox}}}

Next: Measuring things Up: Commands Previous: Definitions