Scope

Horizontal Spacing Control

Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Specifying Spaces, Lengths, and Boxes in L^{A}TEX

Michael S. Pukish

Electrical and Computer Engineering Auburn University

July 7, 2010

1 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

2 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Scope

This presentation covers L^{A}TEX spaces, lengths, and boxes as these elements apply to inline text structure of documents. These concepts apply to many areas of L^{A}TEX. For clarification, this presentation will not cover the application of spaces, lengths, and boxes as they apply to:

equations graphics figures etc.

3 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

4 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

Horizontal Spacing Control

hspace{} and hspace*{}

The standard \hspace{length} command will simply trigger a newline if it runs out of space:

One Two Three Four

                                         \hspace{.125in} One
                                         \hspace{.125in} Two
                                         \hspace{.125in} Three
                                         \hspace{.45in} Four

But \hspace*{length} will enforce the specified space (within a paragraph):

One Two Three Four

                                         \hspace*{.125in} One
                                         \hspace*{.125in} Two
                                         \hspace*{.125in} Three
                                         \hspace*{.45in} Four

Note: \hspace{} and \hspace*{} are equivalent at locations other than at the end of a line.

5 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

Horizontal Spacing Control

Font Size and hspace{}

When using horizontal space together with text, it may make sense to make the space adjust its size relative to the size of the current font. This can be done by using the text-relative units em and ex:

big y_{tin y}

                                         {\Large{}big\hspace{1em}y} \\
                                         {\tiny{}tin\hspace{1em}y}

6 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

Horizontal Spacing Control

hspace{} and stretch{}, hfill

The command \stretch{length} , used in conjunction with the \hspace{} command, generates a special “rubber space” in which all the remaining space on a line is filled up:

  x  x  _{x \hspace{\stretch{1}} x}

The numeral argument does not have significance unless a succession of \hspace{\stretch{}} commands are issued on the same line. In this case, the numerals represent respective proportions of all \stretch{} commands issued on the same line:

a  b  c

                                         a \hspace{\stretch{1}} b
                                         \hspace{\stretch{3}} c

If only an evenly proportional spacing is needed between elements on a line, use the \hfill command such as:

pip pop bing plop

                                         pip \hfill pop
                                         \hfill bing \hfill plop

7 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

8 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

Vertical Spacing Control

vspace{} and vspace*{}

Logically following from \hspace{} and \hspace*{} ( …), the

commands \vspace{length} and \vspace*{length} operate not

between lines within a paragraph, but on the vertical space between paragraphs themselves. These commands should normally be used between two empty lines. If the space should be preserved and spread across the bottom and top of successive pages, use the starred version

of the command, \vspace*{}, instead of \vspace{} :

First paragraph: This produces …

Second Paragraph: No effect.(document only!!)

Third Paragraph: But now we have what we want.

                                       First paragraph: This produces
                                       \ldots \vspace{2ex}
                                       Second Paragraph: No effect.
                                       (document only!!)
                                       \vspace{2ex}
                                       Third Paragraph: But now
                                       we have what we want.

9 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

Vertical Spacing Control

vspace{} and stretch{}, vfill

The \stretch{} command can be used in conjunction with the

\vspace*{}, and \vspace{} commands such as:
Hi! \vspace{stretch{1}} something \vspace{stretch{3}} else \pagebreak

… in order to define relative proportional vertical spacing on a page between structures similar to its use with the \hspace{} commands. Since an example would require an entire page top to bottom, one is not shown. Use your imagination.

If only an evenly proportional vertical spacing is needed between elements on a page, use the \vfill command similarly to usage of the \hfill command.

10 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

Vertical Spacing Control

Other vertical spacers

For custom spacing between lines within a paragraph, the `\\[length]' command is the only way to go as in:

The next line is spaced 10pt below this one

Here it is.

                                         The next line is spaced 10pt
                                         below this one \\[10pt]
                                         Here it is.

The \bigskip, \medskip, and \smallskip commands can be used

as alternative vertical line spacers within a paragraph if an exact spacing is not required.

11 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

12 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes

What are Boxes ?

The underlying structure of L^{A}TEX basically typsets all letters, words, sentences, paragraphs, figures, tables, etc., into “boxes”. Multiple of these elements on a page are then further grouped into enclosing “boxes”. We can manipulate and emphasize these boxes in various ways.

13 / 22

Scope

Horizontal Spacing Control

Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes

parbox{} and minipage

The

\parbox[pos]{width}{text} and \begin{minipage}[pos]{width}text \end{minipage}

commands can place a paragraph within a box. The ‘minipage’ method is more powerful as far as what you can do within a box. You can explore that on your own.

As an example:

Here is a basic box around a paragraph. We have set a reasonable width relative to textwidth, and the text is centered vertically. Note that the ‘pos’ variable can be either ‘t’, ‘b’, or ‘c’ to designate vertical alignment.

\parbox[c]{\textwidth}{
Here is a basic box around a
paragraph.  We have set a
reasonable width relative to
textwidth, and the text is
centered vertically.  Note
that the `pos' variable can
be either `t', `b', or `c' to
designate vertical alignment.}

14 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes

makebox{} and mbox

The \makebox[width][pos]{text} command is meant to operate on a single line with added horizontal control:

A simple example.

                                         \makebox[\textwidth][s] {
                                         A simple example.
                                         }

Width is optional and specified as before, but ‘pos’ is either ’l’, ’r’, or ’s’ for horizontal flushleft, flushright, or spread, respectively.

The \mbox{text} command simply defines a box which will automatically set to the width of the specified text without additional options.

15 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes

framebox{} and fbox

The \framebox[width][pos]{text} command is exactly the same as the \makebox command, except that it puts a frame around the outside of the box that it creates:

A simple example.

                                         \framebox[\textwidth][s] {
                                         A simple example.
                                         }

The \fbox{text} command is exactly the same as the \mbox{text} command, except that it puts a frame around the outside of the box that it creates.

16 / 22

Scope

Horizontal Spacing Control

Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes

Example so far

An example combining the box structures explored so far is adapted from the “Not So Short … ” document by Oetiker:

c e n t r a l s p r e a d Guess Im framed now!

Bummer, I am too wide

never mind, so am I Can you read this?

\makebox[.6\textwidth]{
c e n t r a l}\par
\makebox[.6\textwidth][s]{
s p r e a d}\par
\framebox[1.1\width]{Guess Im
framed now!} \par
\framebox[0.8\width][r]{Bummer,
I am too wide} \par
\framebox[1cm][l]{never
mind, so am I}
Can you read this?}

17 / 22

Scope

Horizontal Spacing Control

Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

Boxes_{raisebox{}}

The \raisebox{lift}[extend-above-baseline][extend-below-baseline]{text}

command gives strange and wonderful vertical control to properties of a box. ’lift’ is the distance the specified text will raise from the baseline of the current line. The other two optional parameters control the line spacing to other text above and below the current raisebox item.

An example is adapted from the “Not So Short … ” document by Oetiker:

Aaaaa aa r g h she shouted, but not even the next one in line noticed that something terrible had happened to her.

\frame {
\parbox[c]{\textwidth} {
\raisebox{-5pt}[0pt][0pt]{\Large
\textbf{Aaaa\raisebox{-0.3ex}{a}
\raisebox{-0.7ex}{aa}
\raisebox{-1.2ex}{r}
\raisebox{-2.2ex}{g}
\raisebox{-4.5ex}{h}}}
she shouted, but not even the next
one in line noticed that something
terrible had happened to her. }}

18 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

19 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own

Conclusion

Further Study On Your Own

There are several other L^{A}TEX spacing, length, and boxing commands which have not been covered in this presentation. Have at it:

\addvspace{length} – extend the vertical space until it reaches length \hrulefill, \dotfill – fill out all available horizontal space with a line or with dots

\rule{width}{thickness} – draw a line

\newsavebox{boxname} – define the variable boxname to store a box

\savebox{boxname}{text}, \sbox{boxname}{text} – save text into

the variable boxname \usebox{boxname} – use material stored in box variable boxname

20 / 22

Scope

Horizontal Spacing Control Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Outline

1 Scope
2 Horizontal Spacing Control

hspace{} and hspace*{} Font Size and hspace{} hspace{} and stretch{}, hfill

3 Vertical Spacing Control

vspace{} and vspace*{} vspace{} and stretch{}, vfill Other vertical spacers

4 Boxes

What are Boxes ? parbox{} and minipage makebox{} and mbox framebox{} and fbox Example so far raisebox{}

5 Further Study On Your Own
6 Conclusion

21 / 22

Scope

Horizontal Spacing Control

Vertical Spacing Control

Boxes

Further Study On Your Own Conclusion

Questions ??^{Conclusion}

22 / 22