Latex Graphics
Latex Graphics
A
T
E
X and pdfL
A
T
E
X
Keith Reckdahl
epslatex at yahoo dot com
Version 3.0
December 8, 2005
This document describes rst how to import graphics into L
A
T
E
X documents and
then covers a wide variety issues about their use. Readers can locate specic infor-
mation by checking the Table of Contents starting on page 5 or the Index starting
on page 120.
Importing graphics begins with specifying the graphicx package
\usepackage{graphicx}
and then using the \includegraphics command to insert the le
\includegraphics{file}
The \includegraphics command is covered in more detail in Section 7 on Page 22.
This document is divided into the following ve parts
Part I: Background Information
This part provides historical information and describes basic L
A
T
E
X terminol-
ogy. It also
The Encapsulated PostScript (eps) format, dierences between eps and
ps les, and methods for converting non-eps graphics to eps.
The graphic formats that can be directly imported with pdfT
E
X (jpeg,
png, pdf, MetaPost) are described.
Freeware/Shareware graphics software is described.
Part II: The L
A
T
E
X Graphics Bundle
This part describes the commands in the graphics bundle which import, scale,
and rotate graphics. This part covers much of the information in the graphics
bundle documentation (reference [6]).
Part III: Using Graphics Inclusion Commands
This part describes how the graphics bundle commands are used to import,
rotate, and scale graphics. Three situations where graphics inclusion is modied
are also covered:
c Copyright 1995-2005 by Keith Reckdahl. Reproduction and distribution is allowed under terms
of the L
A
T
E
X Project Public License (LPPL). See http://www.latex-project.org/lppl/ for the
details of the LPPL license.
1
Compressed eps les and non-eps graphic formats (tiff, gif, jpeg,
pict, etc.) can also be inserted on-the-y when dvips is used with an
operating system which supports pipes (such as Unix). When using other
operating systems, the non-eps graphics must be converted to eps be-
forehand.
Since neither L
A
T
E
X nor dvips has any built-in decompression or graphics-
conversion capabilities, that software must be provided by the user.
Since many graphics applications support only ascii text, the psfrag
system allows text in eps les to be replaced with L
A
T
E
X symbols or
mathematical expressions.
When an eps graphic is inserted multiple times (such as a logo behind the
text or in the page header) the nal PostScript includes multiple copies
of the graphics. When the graphics are not bitmapped, a smaller nal
PostScript le can be obtained by dening a PostScript command for the
graphics.
Part IV: The gure Environment
There are several advantages to placing graphics in gure environments. Figure
environments automatically number graphics, allowing them to be referenced
or included in a table of contents. Since the gures can oat to avoid poor
page breaks, it is much easier to produce a professional-looking document.
In addition to general information about the gure environment, this section
describes the following gure-related topics:
How to customize the gure environment, such as adjusting gure place-
ment, gure spacing, caption spacing, and adding horizontal line between
the gure and the text. Caption formatting can also be customized, al-
lowing users to modify the style, width, and font of captions.
How to create marginal gures and wide gures which extend into the
margins.
How to produce gures with landscape orientation in a portrait document.
How to place captions beside the gure instead of below or above the
gure.
For two-sided documents, how to ensure that a gure appears on an odd
or even page. Also, how to ensure that two gures appear on facing pages.
How to create boxed gures.
Part V: Complex Figures
This part describes how to construct complex gures that contain multiple
graphics.
How to form side-by-side graphics, side-by-side gures, and side-by-side
subgures.
How to place a table next to a gure in the same oat.
How to stack multiple rows of gures.
How to construct continued gures which can span multiple pages.
2
Where to Get this Document
This document is available in pdf and PostScript form as
CTAN/info/epslatex/english/epslatex.ps
CTAN/info/epslatex/english/epslatex.pdf
where CTAN can be replaced by any of the following ctan (Comprehensive T
E
X
Archive Network) sites and mirrors
England ftp://ftp.tex.ac.uk/tex-archive/
Germany ftp://ftp.dante.de/tex-archive/
Denmark ftp://tug.org/tex-archive
France ftp://ftp.loria.fr/pub/ctan
Russia ftp://ftp.chg.ru/pub/TeX/CTAN
Vermont, USA ftp://ctan.tug.org/tex-archive/
Florida, USA ftp://ftp.cise.ufl.edu/pub/mirrors/tex-archive/
Utah, USA ftp://ctan.math.utah.edu/tex-archive/
Korea ftp://ftp.ktug.or.kr/tex-archive/
Japan ftp://ftp.riken.go.jp/pub/tex-archive/
Hong Kong ftp://ftp.comp.hkbu.edu.hk/pub/TeX/CTAN/
Singapore ftp://ftp.nus.edu.sg/pub/docs/TeX/
New Zealand ftp://elena.aut.ac.nz/pub/CTAN
Australia ftp://ctan.unsw.edu.au/tex-archive/
India http://mirror.gnowledge.org/ctan/
South Africa ftp://ftp.sun.ac.za/CTAN/
Brazil ftp://ftp.das.ufsc.br/pub/ctan/
A complete list of ctan mirrors can be obtained from the CTAN.sites le at any
ctan site.
Jean-Pierre Drucberts French translation of Version 2.0 of this document is avail-
able in pdf and PostScript as
CTAN/info/epslatex/french/fepslatex.pdf
CTAN/info/epslatex/french/fepslatex.ps
Acknowledgments
I would like to thank David Carlisle for providing a great deal of assistance with
this document. Donald Arseneau, Robin Fairbairns, Jim Hafner, Piet van Oostrum,
Rolf Niepraschk, Axel Sommerfeldt, and other contributors to the comp.text.tex
newsgroup provided much of the information for this document. Thanks to Jean-
Pierre Drucbert for translating this document into French.
Thanks also goes to the many other people who provided me with valuable sug-
gestions and bug reports for this document.
3
To Becky,
my wonderful wife and partner in exhaustion,
and to Elise and Eric,
who have disrupted and enriched my life
more than I ever could have imagined.
4
Contents
I Background Information 9
1 Introduction 9
2 L
A
T
E
X Terminology 10
3 Encapsulated PostScript 11
3.1 Forbidden PostScript Operators . . . . . . . . . . . . . . . . . . . . . . 12
3.2 The EPS BoundingBox . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.3 Converting PS les to EPS . . . . . . . . . . . . . . . . . . . . . . . . 13
3.4 Fixing Non-standard EPS les . . . . . . . . . . . . . . . . . . . . . . 14
4 How EPS Files are Used by L
A
T
E
X 14
4.1 Line Buer Overow . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 PDF Graphics 15
5.1 JPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.2 PNG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3 PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 MetaPost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.5 PurifyEPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6 Graphics Software 17
6.1 Ghostscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6.2 Graphics-Conversion Programs . . . . . . . . . . . . . . . . . . . . . . 17
6.3 Level 2 EPS Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.4 Editing PostScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
II The L
A
T
E
X Graphics Bundle 22
7 Graphics Inclusion 22
7.1 Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.2 Graphics Inclusion for DVIPS-style Documents . . . . . . . . . . . . . 22
7.3 Graphics Inclusion for pdfL
A
T
E
X Documents . . . . . . . . . . . . . . . 22
7.4 Documents to be Processed by both L
A
T
E
X and pdfL
A
T
E
X . . . . . . . 23
7.5 Specifying Width, Height, or Angle . . . . . . . . . . . . . . . . . . . . 24
8 Rotating and Scaling Objects 27
8.1 The scalebox Command . . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.2 The resizebox Commands . . . . . . . . . . . . . . . . . . . . . . . . . 27
8.3 The rotatebox Command . . . . . . . . . . . . . . . . . . . . . . . . . 28
9 Advanced Graphics-Inclusion Commands 29
9.1 The DeclareGraphicsExtensions Command . . . . . . . . . . . . . . . 29
9.2 The DeclareGraphicsRule Command . . . . . . . . . . . . . . . . . . . 30
5
III Using Graphics-Inclusion Commands 32
10 Horizontal Spacing and Centering 32
10.1 Horizontal Centering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
10.2 Horizontal Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11 Rotation, Scaling, and Alignment 33
11.1 Dierence Between Height and Totalheight . . . . . . . . . . . . . . . 33
11.2 Scaling of Rotated Graphics . . . . . . . . . . . . . . . . . . . . . . . . 33
11.3 Alignment of Rotated Graphics . . . . . . . . . . . . . . . . . . . . . . 34
11.4 Minipage Vertical Alignment . . . . . . . . . . . . . . . . . . . . . . . 36
12 Overlaying Two Imported Graphics 38
12.1 Overpic Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13 Using Subdirectories 39
13.1 T
E
X Search Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
13.2 Temporarily Changing the T
E
X Search Path . . . . . . . . . . . . . . . 40
13.3 Graphics Search Path . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
13.4 Conserving Pool Space . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
14 Compressed and Non-EPS Graphics Files in dvips 42
14.1 Compressed EPS Example . . . . . . . . . . . . . . . . . . . . . . . . . 43
14.2 Non-EPS Graphic Files . . . . . . . . . . . . . . . . . . . . . . . . . . 43
14.3 GIF Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
14.4 T
E
X Search Path and dvips . . . . . . . . . . . . . . . . . . . . . . . . 44
15 The PSfrag Package 45
15.1 PSfrag Example #1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
15.2 PSfrag Example #2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
15.3 L
A
T
E
X Text in EPS File . . . . . . . . . . . . . . . . . . . . . . . . . . 48
15.4 Figure and Text Scaling with PSfrag . . . . . . . . . . . . . . . . . . . 48
15.5 PSfrag and PDFT
E
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
16 Including An EPS File Multiple Times 49
16.1 Dening a PostScript Command . . . . . . . . . . . . . . . . . . . . . 50
16.2 Graphics in Page Header or Footer . . . . . . . . . . . . . . . . . . . . 52
16.3 Watermark Graphics in Background . . . . . . . . . . . . . . . . . . . 53
IV The Figure Environment 55
17 The Figure Environment 55
17.1 Creating Floating Figures . . . . . . . . . . . . . . . . . . . . . . . . . 56
17.2 Figure Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
17.3 Clearing Unprocessed Floats . . . . . . . . . . . . . . . . . . . . . . . . 59
17.4 Too Many Unprocessed Floats . . . . . . . . . . . . . . . . . . . . . . 60
18 Customizing Float Placement 61
18.1 Float Placement Counters . . . . . . . . . . . . . . . . . . . . . . . . . 61
18.2 Figure Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
18.3 Suppressing Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6
19 Customizing the gure Environment 64
19.1 Figure Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
19.2 Horizontal Lines Above/Below Figure . . . . . . . . . . . . . . . . . . 65
19.3 Caption Vertical Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . 66
19.4 Caption Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
19.5 Caption Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
19.6 Moving Figures to End of Document . . . . . . . . . . . . . . . . . . . 68
19.7 Adjusting Caption Linespacing . . . . . . . . . . . . . . . . . . . . . . 68
20 Customizing Captions with caption package 69
20.1 Caption Package Overview . . . . . . . . . . . . . . . . . . . . . . . . . 69
20.2 Caption Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
20.3 Customizing Captions with Caption Command . . . . . . . . . . . . . 70
20.4 Caption Package Examples . . . . . . . . . . . . . . . . . . . . . . . . 76
20.5 Further Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
21 Non-Floating Figures 87
21.1 Non-oating Figures without the caption package . . . . . . . . . . . . 88
21.2 The oat Packages [H] Placement Option . . . . . . . . . . . . . . . . 89
22 Marginal Figures 89
23 Wide Figures 90
23.1 Wide Figures in One-sided Documents . . . . . . . . . . . . . . . . . . 90
23.2 Wide Figures in Two-sided Documents . . . . . . . . . . . . . . . . . . 91
24 Landscape Figures 91
24.1 Landscape Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 92
24.2 Sidewaysgure Environment . . . . . . . . . . . . . . . . . . . . . . . . 93
24.3 Rotcaption Command . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
25 Captions Beside Figures 95
25.1 The Sidecap Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
25.2 Side Captions without Sidecap . . . . . . . . . . . . . . . . . . . . . . 96
26 Figures on Even or Odd Pages 97
26.1 Figures on Facing Pages . . . . . . . . . . . . . . . . . . . . . . . . . . 99
27 Boxed Figures 99
27.1 Box Around Graphic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
27.2 Box Around Figure and Caption . . . . . . . . . . . . . . . . . . . . . 99
27.3 Customizing fbox Parameters . . . . . . . . . . . . . . . . . . . . . . . 101
27.4 The Fancybox Package . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
V Complex Figures 104
28 Side-by-Side Graphics 104
28.1 Side-by-Side Graphics in a Single Figure . . . . . . . . . . . . . . . . . 104
28.2 Side-by-Side Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
28.3 Side-by-Side Subgures . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7
29 Separate Minipages for Captions 108
30 Placing a Table Beside a Figure 109
31 Stacked Figures and Subgures 110
31.1 Stacked Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
31.2 Stacked Subgures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
32 The subg package 112
32.1 The Suboat Command . . . . . . . . . . . . . . . . . . . . . . . . . . 112
32.2 Customizing subg with captionsetup Command . . . . . . . . . . . . 113
32.3 The ContinuedFloat Command . . . . . . . . . . . . . . . . . . . . . . 115
33 Continued Figures and Subgures 115
33.1 Continued Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
33.2 Continued Subgures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
References 118
Index 120
8
Part I
Background Information
1 Introduction
When T
E
X was written, PostScript/eps, jpeg, gif, and other graphic formats did History
not exist. As a result, Knuths dvi format does not have direct support for imported
graphics. However, T
E
X allows dvi les to contain \special commands which pass
commands to programs which use dvi les. This allowed T
E
X and L
A
T
E
X to import
any graphic format which is supported by the dvi program being used.
For many years, dvi les were usually converted to PostScript and the standard
imported-graphic format was Encapsulated PostScript (eps), which is a subset of
the PostScript language. Inserting eps graphics in L
A
T
E
X originally required the
low-level \special command. To make graphic-insertion easier and more portable,
two higher-level packages epsf and psg were written for L
A
T
E
X2.09. In epsf, the
graphics insertion was done by the \epsfbox command, while three other commands
controlled graphic scaling. In psg, the \psfig command not only inserted graphics,
it also scaled and rotated them. While the psg syntax was popular, its code was not
as robust as epsf. As a result, the epsg package was created as a hybrid of the two
graphics packages, with its \epsfig command using the \psfig syntax and much
of the more-robust \epsfbox code. Unfortunately, \epsfig still used some of the
less-robust \psfig code.
With the release of L
A
T
E
X2
in 1994, the L
A
T
E
X3 team addressed the general L
A
T
E
X
Graphics
Bundle
problem of inserting graphics in L
A
T
E
X. Their eorts produced the L
A
T
E
X graphics
bundle
1
which contains totally re-written commands that are more ecient, more
robust, and more portable than other graphics-insertion commands.
The graphics bundle contains the standard graphics package and the extended
graphicx package. While both packages contain an \includegraphics command,
the packages contain dierent versions of \includegraphics. The graphicx version
uses named arguments (similar to the \psfig syntax) which, although convenient,
violate the L
A
T
E
X syntax guidelines which require that optional arguments be po-
sitional. As a compromise, two versions of \includegraphics were written, with
the graphics package following the L
A
T
E
X syntax guidelines and the graphicx package
using the more-convenient named arguments. The graphicx \includegraphics sup-
ports scaling and rotating, but the graphics \includegraphics command must be
nested inside \rotatebox or \scalebox commands to produce rotating or scaling.
This document uses the graphicx package because its syntax is more convenient
than the graphics syntax. Since both packages have the same capabilities, the exam-
ples in this document can also be performed with the graphics package, although the
resulting syntax may be more cumbersome and slightly less ecient. For a more-
detailed description of the packages, see the graphics bundle documentation [6].
For backward-compatibility, the graphics bundle also includes the epsg package
which replaces the original L
A
T
E
X2
2
L
1
L
2
P
1
P
2
Figure 10: With PSfrag Replacement
15.2 PSfrag Example #2
This example demonstrates how the \shortstack, \colorbox, and \fcolorbox com-
mands can be used with \psfrag.
shortstack The \shortstack command allows text to be stacked vertically, which
can be used to substitute multiple lines of text for a single line of text. The
lines of text are separated by the \\ command.
colorbox The \colorbox command (part of the color package, which is distributed
with L
A
T
E
X) places a rectangular color background behind an object. The
distance that the background extends beyond the object is controlled by the
\fboxsep length. For example,
\colorbox{white}{text}
places a rectangular white background behind text. See reference [6] for details
on \colorbox.
With psfrag, \colorbox is useful for placing text at a location where lines or
shading would make it dicult to view the text. Placing a white background
behind the text prevents the drawing from obstructing the text.
fcolorbox The \fcolorbox command (also part of the color package) is similar to
the \colorbox command, except that a frame is drawn around the background.
The command \fcolorbox{black}{white}{text} puts a white background
with a rectangular black frame behind text.
The thickness of the frame is controlled by the length \fboxrule and the
spacing between the frame and the text/object is controlled by the length
\fboxsep.
Figure 11 shows the graphic without psfrag substitution. The commands
\psfrag{q1}[][]{\colorbox{white}{$q_1$}}
\psfrag{base}{\fcolorbox{black}{white}{Base}}
\psfrag{Actuator}[l][l]{\shortstack{Hydraulic\\ Actuator}}
\includegraphics{mass.eps}
use psfrag to produce the graphics in Figure 12.
47
q1 Actuator
base
Figure 11: Without PSfrag Replace-
ment
q
1
Base
Hydraulic
Actuator
Figure 12: With PSfrag Replacement
15.3 L
A
T
E
X Text in EPS File
The recommended and most popular method for using psfrag is the \psfrag com-
mand described in the previous section. An alternative, less ecient, method for
using psfrag is the \tex command, which embeds the L
A
T
E
X text directly in the eps
le. See [27] for more information.
15.4 Figure and Text Scaling with PSfrag
If a graphic using psfrag is scaled, the psfrag text is scaled along with the graphic.
As a result, a subtlety of the graphicx package aects the size of the text.
When the width, height, or totalheight options are used to size the graphic
\includegraphics[width=3in]{file.eps}
the psfrag text is inserted after the scaling. Conversely,
\resizebox{3in}{!}{\includegraphics{file.eps}}
Includes the graphic at its natural size, inserts the psfrag text, and then scales
both the graphics and the text.
Similarly, when scaling options are specied before rotation
\includegraphics[width=3in,angle=30]{file.eps}
the scaling is implicitly handled by the graphics inclusion function. However,
when scaling options are specied after rotation
\includegraphics[angle=30,width=3in]{file.eps}
the graphic is rst included at its natural size, then rotated, and then scaled.
Since psfrag replaces the new text during the graphics inclusion, the second
command scales the new psfrag text while the rst command does not. When
the included size of the eps graphic greatly diers from its natural size, the
two commands produce very dierent results.
See [27] for more information on the scaling of psfrag text.
15.5 PSfrag and PDFT
E
X
psfrag cannot be used with pdfT
E
X. If psfrag substitution is needed, one option is
to use the L
A
T
E
X-to-dvi-to-PostScript-to-pdf route that was used before pdfT
E
X.
While this allows psfrag substitution, users lose the advantages that pdfT
E
X pro-
vides.
A better (although more laborious) method is to use psfrag indirectly with
pdfT
E
X. This allows psfrag substitution while also keeping the advantages of pdfT
E
X.
48
1. For each graphic that uses psfrag, create a separate L
A
T
E
X le containing
the psfrag commands and the \includegraphics command. You must use
\pagestyle{empty} to prevent page numbers from being placed on the page.
Assume these psfrag L
A
T
E
X les are named
GraphicFrag00.tex
GraphicFrag01.tex
...
2. At the operating system command line, perform the following steps
latex GraphicFrag00.tex
dvips -E GraphicFrag00
epstool --copy --bbox GraphicFrag00.ps GraphicFrag00.eps
epstopdf GraphicFrag00.eps
The rst command creates GraphicFrag00.dvi. The second command cre-
ates GraphicFrag00.ps. The third command calculates the BoundingBox for
GraphicFrag00.ps and inserts the BoundingBox and contents of GraphicFrag00.ps
into GraphicFrag00.eps. The last command converts GraphicFrag00.eps into
pdf format.
3. Repeat step 2 for GraphicFrag01.tex, . . .
4. Use \includegraphics to include the resulting pdf les
GraphicFrag00.pdf
GraphicFrag01.pdf
...
into the original L
A
T
E
X le.
5. Process the L
A
T
E
X le with pdflatex.
16 Including An EPS File Multiple Times
When the same eps graphic is inserted multiple times, its eps code appears multiple
times in the nal ps le. In particular, this often happens when a logo or other
graphics are inserted into a documents header or footer. This section describes
improved methods for inserting a graphic multiple times.
There are four common methods for including the same eps graphics many times
1. Use \includegraphics{file.eps} wherever you want the graphic. This has
two problems
(a) L
A
T
E
X must nd and read the le every time \includegraphics is used.
(b) The eps graphics commands are repeated in the nal ps le, producing
a large le.
2. Save the graphics in a L
A
T
E
X box and use the box wherever you want the
graphic. This saves L
A
T
E
X time since it must only nd and read the le once.
However, it does not reduce the size of the nal PostScript le.
At the beginning of the le, include the following commands
\newsavebox{\mygraphic}
\sbox{\mygraphic}{\includegraphics{file.eps}}
Then use the command \usebox{\mygraphic} wherever you want the graphic.
(The graphics can be scaled by placing the \usebox command inside a \scalebox
or \resizebox command.)
49
3. When the eps le contains vector graphics (as opposed to bitmapped graphics),
it is possible to write a PostScript command which draws the graphics
21
. The
graphic can then be included by issuing the PostScript command wherever the
graphic is needed. Section 16.1 on Page 50 describes this procedure.
Since the nal PostScript le includes the graphics commands only once, the
nal PostScript le is much smaller. Note that since the graphics commands
are stored in printer memory while the nal PostScript le is being printed,
this method may cause the printer to run out of memory and not print the
document.
Although this method results in a small nal PostScript le, it still requires
L
A
T
E
X to nd and read the le containing the PostScript commands.
4. Like the previous method, dene a PostScript command which draws the graph-
ics, but include this command in a L
A
T
E
X box. This results in a small nal
PostScript le and only requires L
A
T
E
X to nd and read the le once.
16.1 Dening a PostScript Command
This section describes how to created a PostScript command which draws the graph-
ics from an eps le containing vector graphics. This procedure does not work if the
eps le contains bitmapped graphics.
To convert the eps graphics into a PostScript command, the eps le must be
broken into two les, one which denes the PostScript dictionary and the graphics
commands, and another which includes the header information and the uses the
previously-dened PostScript command. For example, an eps le created by Xfig
has the form
%!PS-Adobe-2.0 EPSF-2.0
%%Title: /tmp/xfig-fig017255
%%Creator: fig2dev Version 2.1.8 Patchlevel 0
%%CreationDate: Sun Sep 3 15:36:01 1995
%%Orientation: Portrait
%%BoundingBox: 0 0 369 255
%%Pages: 0
%%EndComments
/$F2psDict 200 dict def
$F2psDict begin
...
%%EndProlog
$F2psBegin
...
$F2psEnd
Where ... indicates unlisted commands. The eps le generally contains three parts
1. The header commands which begin with %
21
While it is possible to construct a PostScript command which draws vector graphics, it turns out
to be a feature of eps that is impossible to construct such a command for bitmapped graphics.
Bitmapped graphics are usually converted to eps by having the image (or colorimage) PostScript
operators read the current le as data. It is not possible to put such constructs into a PostScript
procedure. It is possible to change the eps le so that it passes the image data as PostScript strings
rather than reading the le, but this is dicult to automate and generally requires a fair amount of
hand editing of the PostScript.
Since most people are not PostScript experts, hand-editing the PostScript is generally not an
option. If the graphic can be described by PostScript vector primitives, it may be possible to use
the kvec program (see page 19) to successfully convert the graphic to vector format.
50
2. The Prolog section which starts with
/$F2psDict 200 dict def
and ends with
%%EndProlog
The Prolog denes the commands in the PostScript dictionary used by the eps
le. In this example, the dictionary is named $F2psDict although other names
can be used.
3. The last part contains the commands used to draw the graphics.
Suppose the above eps le is named file.eps. Create the les file.h and file.ps
where file.h contains
/$F2psDict 200 dict def
$F2psDict begin
...
%%EndProlog
/MyFigure {
$F2psBegin
...
$F2psEnd
} def
and file.ps contains
%!PS-Adobe-2.0 EPSF-2.0
%%Title: /tmp/xfig-fig017255
%%Creator: fig2dev Version 2.1.8 Patchlevel 0
%%CreationDate: Sun Sep 3 15:36:01 1995
%%Orientation: Portrait
%%BoundingBox: 0 0 369 255
%%Pages: 0
%%EndComments
$F2psDict begin MyFigure end
file.h denes the dictionary and denes the PostScript command /MyFigure, while
file.ps contains the header information and uses the PostScript command dened
in file.h. In particular, it is important that the file.ps header includes the
%!PS... line and the BoundingBox line. The graphics can then be used in the L
A
T
E
X
document as
\documentclass{article}
\usepackage{graphicx}
\special{header=file.h}
\begin{document}
...
\includegraphics[width=2in]{file.ps}
...
\includegraphics[totalheight=1in]{file.ps}
...
\end{document}
Note that the original le file.eps is not used. Since the graphics commands in
file.h are only included once, the nal PostScript le remains small. However,
this still requires L
A
T
E
X to nd and read file.ps whenever the graphics are used.
The following commands save the graphics in a L
A
T
E
X box to produce a small nal
PostScript le while reading file.ps only once.
\documentclass{article}
\usepackage{graphicx}
\special{header=file.h}
\newsavebox{\mygraphic}
\sbox{\mygraphic}{\includegraphics[width=2in]{file.ps}}
51
\begin{document}
...
\usebox{\mygraphic}
...
\resizebox*{1in}{!}{\usebox{\mygraphic}}
...
\end{document}
Like the previous example, these commands produce a 2-inch wide graphic and an-
other graphic whose totalheight is 1 inch.
16.2 Graphics in Page Header or Footer
An easy method of including graphics in the heading is to use the fancyhdr package
(an improved version of the old fancyheadings package) which is documented by [16].
The header consists of three parts: its left eld, its center eld, and its right eld.
The \fancyhead command species the contents of the header elds, with the L,C,R
options specifying which eld(s) the command modies. For example
\pagestyle{fancy}
\fancyhead[C]{My Paper}
causes the center header eld to be My Paper, while
\pagestyle{fancy}
\fancyhead[L,R]{\textbf{Confidential}}
causes both the left and right header elds to be Condential. If no L,C,R option
is specied, it applies to all three header elds. Thus \fancyhead{} is used to clear
all the header elds. The \fancyfoot command similarly species the left, center,
and right footer elds.
The commands in the fancyhdr package can insert graphics in the headers and Graphics in
Page
Header/Footer
footers. For example, after splitting the eps le file.eps into the two le file.h
and file.ps as described in Section 16.1 on Page 50, the commands
\documentclass{article}
\usepackage{fancyhdr,graphicx}
\renewcommand{\headheight}{0.6in} %% must be large enough for graphic
\renewcommand{\textheight}{7.5in}
% Define PostScript graphics command
\special{header=file.h}
% Save graphics in LaTeX box
\newsavebox{\mygraphic}
\sbox{\mygraphic}{\includegraphics[totalheight=0.5in]{file.ps}}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyhead[L]{\usebox{\mygraphic}}
\fancyfoot{} % clear all footer fields
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
...
\end{document}
places the graphics at the top left of each fancy page with a 0.5 pt horizontal line
drawn under the header. Additionally, the page number is placed at the bottom
52
center of each page, with no horizontal line drawn above the footer. Note that this
does not aect plain pages.
When the [twoside] documentclass option is used, one may want to individually Odd/Even
Headings
specify the odd and even page headers/footers. The E,O \fancyhead options specify
the even and odd page headers, respectively. If the E,O options are not specied, the
command applies to both even and odd pages. Likewise the E,O \fancyfoot options
specify the even and odd page footers. For example,
\pagestyle{fancy}
\fancyhead[LE]{My Paper}
\fancyhead[RO]{My Name}
\fancyfoot[C]{\thepage}
places My Paper in the upper left of even fancy pages, My Name in the upper
right of odd fancy pages, and the page number in the bottom center of all fancy
pages. Replacing the
\fancyhead[L]{\usebox{\mygraphic}}
command in the above example with
\fancyhead[LE,RO]{\usebox{\mygraphic}}
places the graphic at the top outside (the left side of even pages, right side of odd
pages) of all fancy pages.
The \fancyhead commands only apply to pages whose style are fancy. Even Modifying
Plain Pages though \pagestyle{fancy} causes the document to have a fancy page style, some
pages (title pages, table of contents pages, the rst page of chapters, etc.) are still
given a plain pagestyle by default.
The \fancypagestyle command can be used to modify the plain pagestyle. For
example, adding the following code to the above example causes the graphic to also
be placed at the upper left of plain pages.
\fancypagestyle{plain}{%
\fancyhead{} % clear all header fields
\fancyhead[L]{\usebox{\mygraphic}}
\fancyfoot{} % clear all footer fields
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}}
When the twoside documentclass option is used, replacing both of the
\fancyhead[L]{\usebox{\mygraphic}}
commands with
\fancyhead[LE,RO]{\usebox{\mygraphic}}
places the graphic at the top outside of every page (both plain and fancy).
16.3 Watermark Graphics in Background
In addition to adding graphics to the headers and footers, the fancyhdr package
can place graphics behind in the text, which is useful for creating a logo or seal
watermark.
The following example places the graphics in file.eps on every page (both fancy
and plain).
53
\documentclass{article}
\usepackage{graphicx,fancyhdr}
%%% store graphics in a box
\newsavebox{\mygraphic}
\sbox{\mygraphic}{\includegraphics[keepaspectratio,
height=0.8\textheight,
width=0.8\linewidth]{file.eps}}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\setlength{\unitlength}{1in}
\begin{picture}(0,0)
\put(-2.2,-6){\usebox{\mygraphic}}
\end{picture}}
\fancypagestyle{plain}{%
\fancyhead{}%
\fancyhead[C]{\setlength{\unitlength}{1in}
\begin{picture}(0,0)
\put(-2.2,-6){\usebox{\mygraphic}}
\end{picture}}}
\begin{document}
...
\end{document}
The above example places the graphics such that their lower left corner is 2.2 inches
to the left and 6 inches below the center of the header. The graphic position can be
adjusted by changing these two numbers.
Since the header is typeset before the text, this example causes the text to appear
on top of the graphics. Since the footer is typeset after the text, putting the graphics
in the footer causes the graphics to appear on top of the text.
If the contents of file.eps contain vector (not bitmapped) graphics, a much
smaller nal PostScript le can be obtained by using the procedure described in
Section 16.1 on Page 50.
16.3.1 eso-pic Package
Another method for adding L
A
T
E
X object on every page is the eso-pic package which
denes a zero-length picture environment with basepoint at the lower left corner of
the page. See the eso-pic package documentation [14] for details.
54
Part IV
The Figure Environment
17 The Figure Environment
When using a word processor, gures appear exactly where the user places them
22
.
Since these gures cannot be split, they often lead to poor page breaks that leave
large chunks of blank space at the bottom of pages. To achieve a professional-
looking document, the author must manually rearrange the gures to avoid these
poor page breaks. This gure-shuing becomes quite tedious, especially since it
must be repeated whenever the document is modied.
L
A
T
E
X provides oating gures which automatically move to esthetically-pleasing
locations, producing professional-looking documents without all of the gure-moving
drudgery. However, these oating gures often bother new users who are accustomed
to manual gure placement. Taking advantage of L
A
T
E
Xs oating gures requires
the following
Dont compose text which is dependent on gure placement.
Using the phrase This gure... or The following gure... requires the gure
to be in a certain location. Using the phrase Figure 14... allows the gure
to be positioned anywhere.
Relax.
Some users get quite worried when a gure isnt placed exactly where they
want it. Figure placement is L
A
T
E
Xs job; users generally do not need to worry
about it.
The following pages describe how the L
A
T
E
X determines oat locations which obey Summary
of Advice typesetting rules for a professional-looking document. For convenience, the solutions
to the most-common oat-placement problems are listed below.
1. Dont handcu L
A
T
E
X. The more oat placement options are given to L
A
T
E
X,
the better it handles oat placement. In particular, the [htbp] and [tbp]
options work well. See Section 17.2 on Page 58.
2. Many people nd the default oat parameters are too restrictive. The following
commands
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
set the oat parameters to more-permissive values. See Section 18.2 on Page 61.
3. L
A
T
E
X allows gures to oat to the top of the current page, thus appearing
before the reference in the text. Users who do not like this behavior should
use the after package [17]. Include \usepackage{flafter} at the beginning
of the document; no other commands are necessary.
22
Although many word processors do allow gures to move around text (or vice-versa), the vast
majority of the users do not use such capability because of either poor implementation by the
software author and/or ignorance/indierence by the document author.
55
4. To guarantee that a gure does not oat past a certain point, use the placeins
package and issue a \FloatBarrier command. See Section 17.3 on Page 59.
Warning, overuse of \FloatBarrier indicates that either the oat-placement
is being micro-managed or the oat parameters are set incorrectly, neither of
which are good.
17.1 Creating Floating Figures
Floating gures are created by putting commands in a figure environment. The
contents of the gure environment always remain in one chunk, oating to produce
good page breaks. The oating gures can be automatically numbered by using the
\caption command. For example, the following commands put the graphic from
graph.eps inside a oating gure
\begin{figure}
\centering
\includegraphics[totalheight=2in]{graph.eps}
\caption{This is an inserted EPS graphic}
\label{fig:graph}
\end{figure}
The graph in Figure~\ref{fig:graph} on Page~\pageref{fig:graph}...
Notes about gures
The optional \label command, can be used with the \ref, and \pageref com-
mands to reference the caption. See Section 17.1.1 for additional information
on references. The \label command must be placed immediately after the
\caption command. Putting the \label before the \caption causes the \ref
command to reference the last reference-able object (which often is the section
or previous gure).
If the gure environment contains no \caption commands, it produces an
unnumbered oating gure.
If the gure environment contains multiple \caption commands, it produces
multiple gures which oat together. This is useful in constructing side-by-
side graphics (see Section 28 on Page 104) or complex arrangements such as in
Section 31 on Page 110.
By default, the caption text is used as the caption and also in the list of gures.
The caption has an optional argument which species the list-of-gure entry.
For example,
\caption[List Text]{Caption Text}
causes Caption Text to appear in the caption, but List Text to appear in
the list of gures. This is useful when long, descriptive captions are used.
The gure environment can only be used in outer paragraph mode, preventing
it from being used inside any box (such as parbox or minipage).
Figure environments inside of paragraphs
....text text text text text text
\begin{figure}
....
\end{figure}
text text text text text text...
are not processed until the end of the paragraph.
56
17.1.1 Dening a Reference Command
Instead of typing
Figure~\ref{fig:graph} on Page~\pageref{fig:graph}
it is more convenient to dene the following command in the document preamble
\newcommand\Figpage[1]{Figure~\ref*{#1} on Page~\pageref*{#1}}
which allows the reference code to shortened to
\Figpage{fig:graph}
Conditional References
The above \Figpage denition always prints both the Figures number and page
number. In cases where the gure appears on the same page as the reference, it may
be desirable to omit the page number. This can achieved by the following code
\newcommand\FigDiff[1]{Figure~\ref*{#1} on Page~\pageref*{#1}}
\newcommand\FigSame[1]{Figure~\ref*{#1}}
\newcommand\Figref[1]{\ifthenelse{\value{page}=\pageref{#1}}
{\FigSame{#1}}{\FigDiff{#1}}}
If the reference and gure are on the same page, the \Figref command calls the
\FigSame command which displays Figure 17. If the reference and gure are on
dierent pages, the \Figref command calls the \FigDiff command which displays
Figure 17 on Page 25.
The varioref package [32] provides addition commands like this for referencing
Figures, Tables, Section, etc.
17.1.2 hyperref Package
The hyperref package allows users to construct hyperlinks within L
A
T
E
X documents,
most commonly in conjunction with pdflatex.
One feature of hyperref is that it redenes the \ref and \cite commands to be
typeset as hyperlinks to the reference. The \ref* and \cite* commands are dened
for references and cites without hyperlinks.
Because the hyperref package redenes many L
A
T
E
X commands, users should order
their \usepackage to make hyperref be the last package loaded.
For more information, see the Hypertext Manual [19].
Hypertext References
When using the hyperref package, the \ref command typesets the gure number
with a hyperlink to the gure. Since the gure number is relatively small, it may
be dicult for readers to click on the actual gure number. To make clicking the
hyperlink easier, the following code
\newcommand\Figlink[1]{\hyperref[#1]{Figure~\ref*{#1}} on Page~\pageref*{#1}}
denes a \Figlink command which turns the entire Figure 17 reference into a
single hyperlink.
57
17.2 Figure Placement
The figure environment has an optional argument which allows users to specify
possible gure locations. The optional argument can contain any combination of the
following letters
h Here: Place the gure in the text where the gure command is located. This
option cannot be executed if there is not enough room remaining on the page.
t Top: Place the gure at the top of a page.
b Bottom: Place the gure at the bottom of a page
23
.
p Float Page: Place the gure on a containing only oats.
Notes on gure placement:
If no optional arguments are listed, the placement options default to [tbp].
The default arguments can be customized by redening the internal command
\fps@figure. For example, the following code
\makeatletter
\def\fps@figure{htbp}
\makeatother
causes the placement options to default to [htbp].
The order in which the placement options are specied does not make any
dierence, as the placement options are always attempted in the order h-t-b-p.
Thus [hb] and [bh] are both attempted as h-b.
The more oat placement options are given to L
A
T
E
X, the better it handles
oat placement. In particular, the [htbp], [tbp], [htp], [tp] options usually
work well.
Single-location options [t], [b], [p] [h] are problematic
24
. If the gure
doesnt t in the specied location, the gure becomes stuck, blocking the
subsequent gures. A Too Many Unprocessed Floats error occurs if this log-
jam of gures exceeds L
A
T
E
Xs limit of 18 unprocessed oats (see Section 17.4
on Page 60).
When L
A
T
E
X tries to place a gure, it obeys the following rules Also see
Reference
[1, pg 198].
1. A gure can only be placed in the locations specied by its placement options.
2. The gure cannot cause the page to be overfull.
3. The oat must be placed on the page where it occurs in the text, or on a later
page
25
. Thus gures can oat later but cannot oat earlier
4. Figures must appear in order. Thus a gure cannot be placed until all previous
gures are placed. Two ramications of this rule are
A gure can never be placed here if there are any unprocessed gures.
23
When a gure is placed at the bottom of a page, it is placed below any footnotes on the page.
Although this may be objectionable, there currently is no way to change this arrangement.
24
In fact, the [h] option should never be used. It is so bad that recent versions of L
A
T
E
X auto-
matically change it to [ht].
25
Since a oat can appear at the top of the page where it occurs in the text, it can appear before
its occurrence in the text. If this is objectionable, the after package can be used to prevent this.
No command is necessary to activate after; just include it in a \usepackage command.
58
One impossible-to-place gure prevents any subsequent gure from be-
ing placed until the end of the document or until L
A
T
E
Xs oat limit is
reached. See Section 17.4 on Page 60.
Similarly, a table cannot be placed until all previous tables are placed. How-
ever, tables can leapfrog gures and vice-versa.
5. The aesthetic rules in Section 18 must be followed. For example, the number
of oats on a page cannot exceed totalnumber. Specifying an exclamation
point in the placement options (e.g., \begin{figure}[!ht]) makes L
A
T
E
X try
really hard by ignoring the aesthetic rules which apply to text pages (! does
not aect the aesthetic rules which apply to oat pages).
17.3 Clearing Unprocessed Floats
A big advantage for using oats is that L
A
T
E
X is not required to place them imme-
diately in the text. Instead, L
A
T
E
X can hold the oat until it can place it at a better
location. When a oat has been read by L
A
T
E
X but not yet placed on the page, it is
called a unprocessed oat. While the oat-placing algorithm works well, sometimes
it is necessary to force L
A
T
E
X to process any unprocessed oats.
Below are three methods for clearing processed oats. These commands should
be used sparingly; their overuse is either a sign you are micro-managing your oat
placement or your oat placement parameters have bad values (see Section 18 on
Page 61).
clearpage
The most basic method for clearing the unprocessed gures backlog is to is-
sue a \clearpage command, which places all unprocessed oats and starts a
new page. While this is eective, it is undesirable as it generally produces a
partially-lled page.
FloatBarrier
For most situations, the best method for forcing oat placement is the \FloatBarrier
command provided by the placeins package. There are three ways of using
placeins
1. The \FloatBarrier command causes all unprocessed oats to be processed
immediately. Unlike \clearpage, it does not start a new page.
2. Since it is often desirable to keep oats in the section in which they were
issued, the section option
\usepackage[section]{placeins}
redenes the \section command, inserting a \FloatBarrier command
before each section.
Note that this option is very strict. For example, if a new section start
in the middle of a page, the section option does not allow a oat from
the old section to appear at the bottom of the page, since that is after the
start of the new section.
3. The below option
\usepackage[below]{placeins}
is a less-restrictive version of the section option. It allows oats to be
placed after the beginning of a new section, provided that some of the old
section appears on the page.
59
The placeins package does not change the oats oat-placement options. For
example, since \FloatBarrier can only place a [t] oat at the top of a page,
the \FloatBarrier command processes a [t] oat by lling the remaining
portion of the current page with whitespace and then placing the [t] oat at
the top of the next page. Similarly, since \FloatBarrier cannot place a [b]
oat here, text is prevented from appearing below it.
Both of these examples once again demonstrate that L
A
T
E
X oat placement is
most eective when multiple oat-placement options (such as [tbp] or [htbp])
are specied.
afterpage/clearpage
The afterpage package provides the \afterpage command which executes a
command at the next naturally-occurring page break. Therefore, using
\afterpage{\clearpage}
causes all unprocessed oats to be cleared at the next page break.
Using \afterpage{\clearpage} command may not always solve oat limit
problems (see Section 17.4 on Page 60). Since it puts does not execute the
\clearpage until the end of the page, additional unprocessed oats may accu-
mulate before the page break.
\afterpage{\clearpage} is especially useful when producing small oatpage
gures. The \floatpagefraction (see Section 18.2 on Page 61) prevents
oatpage oats which are too small from being placed on a oat page.
Furthermore, since the ! oat-placement modier does not apply to oat
pages, [!p] does not override the \floatpagefraction restriction. Using
\afterpage{\clearpage} is an easy method to override the \floatpagefraction
restriction without causing a partially-lled text page.
17.4 Too Many Unprocessed Floats
If a oat cannot be processed immediately, it is placed on the unprocessed oat queue
until it can be processed. Since, L
A
T
E
X only has room for 18 oats on this queue,
having more than 18 unprocessed oats produces a Too Many Unprocessed Floats
error. There are four possible causes for this error:
1. The most common problem is that the oat placement options are incompatible
with the oat placement parameters. For example, a [t] gure whose height
is larger than \topfraction becomes stuck. Since the other single-position
options have similar problems, specify as many oat placement options as pos-
sible.
2. Incompatible oat fraction values may make it impossible to place certain
oats. To avoid this, make sure any oat fraction values satisfy the Section 18.2
guidelines.
3. In rare situations, users with many oats and many \marginpar notes (which
use the same queue), may need a larger unprocessed oat queue. Using the
moreoats package increases the size of the unprocessed oat queue from 18 to
36.
4. L
A
T
E
Xs oat placement queue is exceeded if more than 18 gures are specied
without any text between them. Possible solutions include
60
(a) Scatter the gures in the text. This allows enough text to accumulate to
force natural pagebreaks, making it easier for L
A
T
E
X to process the oats.
(b) Put \clearpage between some gures. This is inconvenient because it
requires some iterations to avoid partially-full pages. Note that
\afterpage{\clearpage}
(which causes a \clearpage at the next naturally-occurring pagebreak)
does not help in this situation because the oat queue limit is reached
before enough text is accumulated in order to trigger a pagebreak.
(c) Since there is no text, the gures dont need to oat. Therefore, the best
solution is probably to use the Section 21 procedure for constructing non-
oating gures, separated by \vspace or \vfill commands to provide
vertical spacing.
18 Customizing Float Placement
The following style parameters are used by L
A
T
E
X to prevent awkward-looking pages
which contain too many oats or badly-placed oats. If these style parameters are
changed anywhere in the document, they do not apply until the next page. How-
ever, if the parameters are changed in the documents preamble, they apply at the
beginning of the document.
18.1 Float Placement Counters
The three counters in Table 6 prevent L
A
T
E
X from placing too many oats on a text
page. These counters do not aect oat pages. Specifying a ! in the oat placement
options causes L
A
T
E
X to ignore theses parameters. The values of these counters are
set with the \setcounter command. For example,
\setcounter{totalnumber}{2}
prevents more than two oats from being placed on any text page.
Table 6: Float Placement Counters
topnumber The maximum number of oats allowed at the top of a text page
(the default is 2).
bottomnumber The maximum number of oats allowed at the bottom of a text
page (the default is 1).
totalnumber The maximum number of oats allowed on any one text page
(the default is 3).
18.2 Figure Fractions
The commands in Table 7 control what fraction of a page can be covered by oats
(where fraction refers to the height of the oats divided by \textheight). The
rst three commands pertain only to text pages, while the last command pertains
only to oat pages. Specifying a ! in the oat placement options causes L
A
T
E
X
to ignore the rst three parameters, but \floatpagefraction is always used. The
value of these fractions are set by \renewcommand. For example,
\renewcommand{\textfraction}{0.3}
61
Table 7: Figure Placement Fractions
\textfraction The minimum fraction of a text page which must be oc-
cupied by text. The default is 0.2, which prevents oats
from covering more than 80% of a text page.
\topfraction The maximum fraction of a text page which can be occu-
pied by oats at the top of the page. The default is 0.7,
which prevents any oat whose height is greater than 70%
of \textheight from being placed at the top of a page.
Similarly, if the combined height of multiple t oats is
greater than 60% of \textheight, they all will not be
placed at the top of a page, even if they number less than
topnumber.
\bottomfraction The maximum fraction of a text page which can be occu-
pied by oats at the bottom of the page. The default is
0.3, which prevents any oat whose height is greater than
40% of \textheight from being placed at the bottom of
a text page.
\floatpagefraction The minimum fraction of a oat page that must be occu-
pied by oats. Thus the fraction of blank space on a oat
page cannot be more than 1-\floatpagefraction. The
default is 0.5.
lets oats cover no more than 70% of a text page.
The default placement fraction values prevent many and/or large oats from Placement
Fraction
Guidelines
dominating text pages and also prevent small gures from being placed in a sea of
whitespace on a oat page. While the default values generally work well, sometimes
they may be a bit too restrictive, resulting in gures oating too far from where they
are issued. In these cases it may be desirable to set the placement fractions to more
permissive values such as
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}
One must take care when adjusting placement fraction values, as unreasonable values
can lead to poor formatting and/or stuck oats. To avoid such problems, the
following guidelines should be used:
\textfraction
Setting \textfraction smaller than 0.15 is discouraged as it produces hard-
to-read pages. If a gures height is more than 85% of \textheight, it almost
certainly looks better by itself on a oat page than squeezed on a text page
with a couple of lines of text below it.
Furthermore, never set \textfraction to zero as permits a text page to have
no text, which confuses L
A
T
E
X and leads to badly-formatted pages.
\topfraction
Never set \topfraction larger than 1 - \textfraction, as that causes con-
tradictions in the oat-placing algorithm.
62
\bottomfraction
Since good typesetting style discourages large bottom gures, \bottomfraction
is generally smaller than \topfraction. Never set \bottomfraction larger
than 1 - \textfraction, as that causes contradictions in the oat-placing al-
gorithm.
\floatpagefraction
If \floatpagefraction is set very small, every oat page contains exactly one
oat, resulting in excessive whitespace around small p gures.
If \floatpagefraction is larger than \topfraction , [tp] gures may be-
come stuck. For example, suppose the height of a [tp] gure is larger than
\topfraction but smaller than \floatpagefraction, it becomes stuck be-
cause it is too large to be placed on a text page and too small to be placed
on a oat page. To prevent such stuck gures, \floatpagefraction and
\topfraction should satisfy the following inequality:
\floatpagefraction \topfraction 0.05
The 0.05 term is due to the dierence in the accounting of vertical space for
text pages and oat pages
26
. Likewise, if [bp] or [hbp] gures are used,
\floatpagefraction and \bottomfraction should also satisfy
\floatpagefraction \bottomfraction 0.05
Note that the default values do not satisfy the second inequality, which may
occasionally cause problems with [bp] and [hbp] gures.
18.3 Suppressing Floats
The \suppressfloats prevents additional oats from appearing at the top or the
bottom of the current page. They do not aect gures with here placement or
those with ! in the placement options.
Putting \suppressfloats[t] immediately before a gure, prevents that oat
from appearing above the place where it appears in the text. The after package
redenes L
A
T
E
Xs oat algorithm to prevent this for the entire document.
Table 8: Suppressoats Options
\suppressfloats[t] Prevents additional gures from appearing at the top of
the current page.
\suppressfloats[b] Prevents additional gures from appearing at the bottom
of the current page.
\suppressfloats Prevents additional gures from appearing at either the
bottom or the top of the current page.
26
Specically, \textfloatsep and the other text-page oat spacing is counted when comparing a
gure with \topfraction, but the oat page spacings are not counted in testing if a gure exceeds
\floatpagefraction. As a result, \textfloatsep divided by \textheight (which is 0.05) should
be subtracted from \topfraction. See Section 19.1 on Page 64 for information on gure spacing.
63
19 Customizing the gure Environment
19.1 Figure Spacing
The lengths in Table 9 control how much vertical spacing is added between two
gures or between a gure and text. Unlike most other L
A
T
E
X lengths, these three
are rubber lengths, which provides spacing which can shrink or expand to provide
better page formatting. These lengths are set with the \setlength command. For
example,
\setlength{\floatsep}{10pt plus 3pt minus 2pt}
sets the nominal value of \floatsep to be 10 points. To improve page formatting,
the oat separation can be as small as 8 points or as large as 13 points.
Since L
A
T
E
X places \intextsep above and below each here oat, two consecu-
tive here oats are separated by two \intextsep spaces. This extra spacing can be
avoiding by combining the two oats into a single oat, although this may result in
a less-attractive layout since it prevents the oat-placement algorithm from placing
the two oats separately.
The lengths listed in Table 9 do not aect the spacing of oats on oat pages.
The oat-page spacing is controlled by the lengths listed in Table 10. The oat-
page spacings often use the fil unit to provide innite stretchability, similar to the
vertical space produced by \vfill. When multiple fil spaces appear in the same
space, they expand proportionally to ll the space. For example, the default oat-
page parameters cause the space between oat-page oats to be double the space
above the top oat or below the bottom oat.
The @ in the names of the Table 10 lengths mean they are internal commands
27
.
As a result, any \setlength command which modies the lengths must be sur-
rounded by \makeatletter and \makeatother. For example,
27
Any user code which accesses or redenes internal commands must be surrounded by
\makeatletter and \makeatother.
Table 9: Figure Spacing for Text Pages
\floatsep For oats at the top or bottom of a page, this is the vertical
spacing between oats. The default is 12pt plus 2pt minus
2pt
\textfloatsep For oats at the top or bottom of a page, this is the vertical
spacing between the oat and the text. The default is 20pt
plus 2pt minus 4pt
\intextsep For oats placed in the middle of a text page (i.e., with the h
placement option), this is the vertical spacing above and below
the oat. The default is 12pt plus 2pt minus 2pt
Table 10: Figure Spacing for Floatpages
\@fptop This is the vertical spacing above the top oatpage oat. The default
is 0pt plus 1.0fil
\@fpsep This is the vertical spacing between oatpage oats. The default is 8pt
plus 2.0fil
\@fpbot This is the vertical spacing below the bottom oatpage oat. The
default is 0pt plus 1.0fil
64
\makeatletter
\addtolength{\@fpsep}{4pt}
\makeatother
increases the space between oatpage oats by 4 points.
19.2 Horizontal Lines Above/Below Figure
Horizontal lines can be automatically drawn between the text and gures which
appear at the top/bottom of the page by redening the
\topfigurerule
\bottomfigurerule
commands. Although \topfigrule and \bottomfigrule are already dened as
L
A
T
E
X commands, the strange way in which they are dened requires them to be
redened with \newcommand instead of \renewcommand.
To avoid disrupting the page formatting, these commands must have a zero
height. Thus drawing 0.4 point line must be accompanied by a 0.4 point vertical
backspace. For example,
\newcommand{\topfigrule}{\hrule\vspace{-0.4pt}}
Since \topfigrule is executed before the \textfloatsep spacing, the above com-
mand provides no spacing between the gure and the line. The following commands
provide 5 points of space between the gure and the line.
\newcommand{\topfigrule}{%
\vspace*{5pt}\hrule\vspace{-5.4pt}}
\newcommand{\botfigrule}{%
\vspace*{-5.4pt}\hrule\vspace{5pt}}
The \topfigrule denition rst moves 5 points down (into the \textfloatsep
spacing) to provide space between the gure and the line. It then draws a 0.4
point horizontal line and moves back up 5.4 points to compensate for the previous
downward motion. Likewise, the \botfigrule command draws a 0.4 point line with
5 points of spacing between the gure and the rule.
Since these commands place 5 points of space between the line and gure, the
spacing between the line and the text is \textfloatsep - 5pt (see Section 19.1 on
Page 64).
The line thickness can be changed from the 0.4 point default by using the \hrule
commands height option
\newcommand{\topfigrule}{%
\vspace*{5pt}{\hrule height0.8pt}\vspace{-5.8pt}}
\newcommand{\botfigrule}{%
\vspace*{-5.8pt}{\hrule height0.8pt}\vspace{5pt}}
Notes on gure rules:
The \topfigrule and \bottomfigrule aect neither oatpage gures nor
here gures (i.e., using the h option). If a here gure happens to be
placed at the top or the bottom of the page, no line is drawn.
To implement its commands, L
A
T
E
X uses many internal commands which users generally do not
need to access. To prevent these internal command names from accidentally conicting with user-
dened names, L
A
T
E
X includes a @ in these internal command names. Since L
A
T
E
X command names
can contain only letters, dening a command whose name contains @ are normally not possible.
However, when it is necessary for users to change the internal commands, the \makeatletter com-
mand causes L
A
T
E
X to treat @ as a letter, thus allowing users to use @ in command names. The
\makeatother command causes L
A
T
E
X to revert to the normal behavior of treating @ as a non-letter.
65
Table 11: Figure Rule Commands
\topfigrule This command is executed after the last oat at the top of a
page, but before the \textfloatsep spacing (see Section 19.1
on Page 64).
\bottomfigrule This command is executed before the rst oat at the bottom
of a page, but after the \textfloatsep spacing.
The horizontal rules are as wide as the text, even if wider gures (see Section 23
on Page 90) are used.
The T
E
X \hrule command was used instead of L
A
T
E
X \rule command because
the \rule would generate additional space when \parskip is not zero.
19.3 Caption Vertical Spacing
L
A
T
E
X assumes that captions are placed below the graphic, placing more vertical
spacing above the caption than below it. As a result, the commands
\begin{figure}
\centering
\caption{Caption Above Graphic}
\includegraphics[width=1in]{graphic}
\end{figure}
produce Figure 13, whose caption is placed quite close to the graphic.
Figure 13: Caption Above Graphic
Graphic
The caption spacing is controlled by the lengths \abovecaptionskip (which is
10pt by default) and \belowcaptionskip (which is zero by default). The standard
L
A
T
E
X commands \setlength and \addtolength are used to modify these lengths.
For example, the commands
\begin{figure}
\setlength{\abovecaptionskip}{0pt}
\setlength{\belowcaptionskip}{10pt}
\centering
\caption{Caption Above Graphic}
\includegraphics[width=1in]{graphic}
\end{figure}
produce Figure 14, which has has no extra space above the caption and 10 points of
space between the caption and the graphic.
Figure 14: Caption Above Graphic
Graphic
If a document has all its captions at the top of its oats, the commands
\setlength{\abovecaptionskip}{0pt}
\setlength{\belowcaptionskip}{10pt}
can be issued in the documents preamble to aect the caption spacing for all the
documents captions (gures and tables). If a document contains captions at the top
of some oats and at the bottom of other oats, it may be desirable to dene the
following command
66
\newcommand{\topcaption}{%
\setlength{\abovecaptionskip}{0pt}%
\setlength{\belowcaptionskip}{10pt}%
\caption}
Then \topcaption{caption text} produces a caption which is properly spaced for
the top of a oat.
Two other methods for producing properly-spaced top captions are
The caption packages position=top option in Table 16 on Page 74 swaps the
meaning of \abovecaptionskip and \belowcaptionskip
The topcapt package [31], denes a \topcaption command which produces a
caption with the \abovecaptionskip and \belowcaptionskip lengths inter-
changed.
19.4 Caption Label
By default, L
A
T
E
X inserts a caption label such as Figure 13: at the beginning of the
the caption. The Figure portion can be changed by redening the \figurename
command. For example, the commands
\begin{figure}
\centering
\includegraphics[width=1in]{graphic}
\renewcommand{\figurename}{Fig.}
\caption{This is the Caption}
\end{figure}
produce Figure 15. The caption font, the : delimiter, and other caption charac-
teristics can be customized with the caption package (see Section 20 on Page 69).
Graphic
Fig. 15: This is the Caption
19.5 Caption Numbering
The default method for numbering the gures is Arabic (1, 2, 3, 4,. . .). This can be
changed by redening the \thefigure command.
The number of the current gure is stored in the figure counter. The \thefigure
command species which of the counter numbering commands (\arabic, \roman,
\Roman, \alph, \Alph) is used to print the counter value. For example,
\renewcommand{\thefigure}{\Roman{figure}}
causes the gures to be numbered with uppercase Roman numerals (I, II, III, IV,. . .).
Notes on gure numbering:
There must be 26 or fewer gures to use the \alph or \Alph commands.
Since Roman numbering produces longer gure numbers (e.g., XVIII vs. 18),
using \Roman or \roman may cause spacing problems in the Table of Figures.
67
19.6 Moving Figures to End of Document
Some journals require that tables and gures be separated from the text. The endoat
package moves all the gures and table to the end of the document. Simply including
the package
\usepackage{endfloat}
activates the package. The package supports many options which can be included in
the \usepackage command, including
Notes such as [Figure 4 about here.] are placed in approximately where the
oats would have appeared in the text. Such notes can be turned o with the
nomarkers package option
\usepackage[nomarkers]{endfloat}
The text of these notes can be changed by redening the \figureplace and
\tableplace commands. For example,
\renewcommand{\figureplace}{%
\begin{center}%
[\figurename~\thepostfig\ would appear here.]%
\end{center}}
changes the \figureplace text.
A list of gures is included before the gures and a list of tables is included
before the tables. The nofiglist and notablist package options suppress
these lists.
The fighead and tabhead package options create section headers for the gures
and tables, respectively.
The gures appear before the tables. The tablesfirst package option reverses
this order.
A \clearpage command is executed after each gure and table, causing each
oat to appear on a page by itself. This can be changed by modifying the
\efloatseparator command. For example,
\renewcommand{\efloatseparator}{\mbox{}}
places an empty \mbox after each oat.
19.7 Adjusting Caption Linespacing
To doublespace a document, include either
\linespread{1.6}
or equivalently
\renewcommand{\baselinestretch}{1.6}
in the preamble
28
. In addition to doublespaced text, this also produces doublespaced
captions and footnotes. To produce doublespaced text and singlespaced captions and
footnotes, use the setspace package
29
.
\usepackage{setspace}
\linestretch{1.5}
A 1.0 linestretch causes single-spaced text, a 1.25 linestretch causes space-and-a-half
spaced text, and a 1.6 linestretch causes doublespaced text.
28
Although it is generally considered poor style, these commands can also be used within a docu-
ment to change the interline spacing. When these commands are used within a document, a fontsize
command such as \normalsize must issued after the line-spacing command to put the new spacing
into eect.
29
Although the doublespace package also sets line spacing, it has not been properly updated to
L
A
T
E
X2, causing it to interact with many packages. As a result, setspace should be used instead.
68
20 Customizing Captions with caption package
Section 19.4 on Page 67 describes how to customize the caption label while Sec-
tion 19.3 on Page 66 describes how to customize the caption vertical spacing. The
caption package
30
provides commands for customizing other caption characteristics.
This section provides an overview of the caption package. Further details are found
in the caption package documentation [11].
The caption package can be used with many types of oats as it ocially supports
the oat, longtable, and subgure packages and it also works with the oatg, rotating,
supertabular, and wrapg packages.
Although it is not described in this document, the ccaption (note the double-c) pack- ccaption
package age also provides commands for customizing captions. It is described in [12].
20.1 Caption Package Overview
There are two aspects to the caption package
The new variants of the \caption command which produce the captions are
described in Section 20.2 and listed in Table 12.
Section 20.3 on Page 70 describes the two methods for specifying caption-
customizing options. There are four types of options:
Font Options customize the caption font
31
. These options are listed in Ta-
ble 14 and Table 15 on Page 73 with examples provided in Section 20.4.1
on Page 76.
Caption Spacing Options customize the caption vertical spacing. These
options are listed in Table 16 on Page 74 with examples provided in Sec-
tion 20.4.2 on Page 77.
Caption Label Options customize the caption label and separator. These
options are listed in Table 17 on Page 74 with examples provided in Sec-
tion 20.4.3 on Page 79.
Caption Formatting Options customize the caption formatting. These op-
tions are listed in Table 18 on Page 75 with examples provided in Sec-
tion 20.4.4 on Page 81.
Note that the tables listing the caption-package options (Tables 13 - 18) are
grouped together on pages 73-75 to facilitate convenient reference. The exam-
ples are grouped together in Section 20.4 on Page 76.
Users can dene a collection of caption options, called caption styles. The entire
collection of options can be specied with the style= option. See Section 20.5.1
on Page 83.
Instead of just using the built-in option values, users can dene their own option
values as described in Section 20.5.2.
30
Version 3 of the caption package replaces previous caption versions as well as the caption2 package.
31
Although caption package provides commands to customize a captions font, not every combi-
nation of font attributes necessarily exists in the font being used. For example, suppose the user
species a font with roman family, small caps shape, and bold series. If that combination is not
supported by the current font, then L
A
T
E
X may instead substitute a font with roman family, upright
shape, and bold series.
69
20.2 Caption Commands
Section 17.1 on Page 56 describes the \caption command and some customization is
described in and Section 19. The caption package provides many more customization
options.
The caption package slightly changes this \caption command and also introduces
new variants as described in Table 12. The highlights include:
The caption package changes the \caption command such that if the optional
argument is specied but empty
\caption[]{caption text}
then no entry is made in the list of gures/tables for that caption.
The new \caption* command displays the caption without a caption label and
without entry in the list of tables.
The new \captionof command allows a particular type of caption to be used
anywhere: gure environment, table environment, or elsewhere in a document.
For example
\begin{figure}
....
\captionof{table}[List of Tables Text]{Table Caption}
\end{figure}
produces a Table caption inside a gure environment. This is useful for
1. Placing a table and gure side-by-side as described in Section 30 on
Page 109).
2. Constructing marginal gures (see Section 22 on Page 89).
3. Constructing non-oating gures (see Section 21 on Page 87).
Note that the \captionof should always be used inside some type of environ-
ment (such as minipage) to avoid page breaks occurring between the caption
and the oat contents.
20.3 Customizing Captions with Caption Command
As mentioned earlier in Section 20.1 on Page 69, the caption package allows the user
to customize the caption font, spacing, label, and format. The options (listed in
Tables 13 - 18) can be specied in either of two ways:
usepackage options
\usepackage[options]{caption} where [options] are any combination of
options specied in Table 13. For example
\usepackage[margin=10pt,font=small,labelfont=bf]{caption}
causes all caption margins to be indented by an additional 10pt on both left
and right sides, with the entire caption (label and text) having a small font
size and the label having a bold font series.
captionsetup command
The command \captionsetup{options} causes specied options to be in ef-
fect for the remaining environment. (A \captionsetup command in a docu-
ments preamble eects the entire document.) For example
\captionsetup{margin=10pt,font=small,labelfont=bf}
70
T
a
b
l
e
1
2
:
c
a
p
t
i
o
n
p
a
c
k
a
g
e
c
a
p
t
i
o
n
C
o
m
m
a
n
d
s
C
o
m
m
a
n
d
D
e
s
c
r
i
p
t
i
o
n
\
c
a
p
t
i
o
n
{
c
a
p
t
i
o
n
t
e
x
t
}
U
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
b
o
t
h
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
a
n
d
f
o
r
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
(
S
a
m
e
b
e
h
a
v
i
o
r
a
s
w
i
t
h
o
u
t
c
a
p
t
i
o
n
p
a
c
k
a
g
e
)
.
\
c
a
p
t
i
o
n
[
l
i
s
t
e
n
t
r
y
]
{
c
a
p
t
i
o
n
t
e
x
t
}
U
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
a
n
d
l
i
s
t
t
e
x
t
f
o
r
e
n
t
r
y
i
n
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
(
S
a
m
e
b
e
h
a
v
i
o
r
a
s
w
i
t
h
o
u
t
c
a
p
t
i
o
n
p
a
c
k
a
g
e
)
.
\
c
a
p
t
i
o
n
[
]
{
c
a
p
t
i
o
n
t
e
x
t
}
U
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
a
n
d
c
r
e
a
t
e
s
n
o
e
n
t
r
y
i
n
L
i
s
t
o
f
F
i
g
-
u
r
e
s
/
T
a
b
l
e
s
.
\
c
a
p
t
i
o
n
*
{
c
a
p
t
i
o
n
t
e
x
t
}
U
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
b
u
t
d
o
e
s
n
o
t
i
n
c
l
u
d
e
c
a
p
t
i
o
n
l
a
b
e
l
o
r
s
e
p
a
r
a
t
o
r
(
s
e
e
F
i
g
u
r
e
1
6
)
.
N
o
e
n
t
r
y
i
s
g
e
n
e
r
a
t
e
d
f
o
r
t
h
e
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
\
c
a
p
t
i
o
n
*
[
l
i
s
t
e
n
t
r
y
]
{
c
a
p
t
i
o
n
t
e
x
t
}
U
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
b
u
t
d
o
e
s
n
o
t
i
n
c
l
u
d
e
c
a
p
t
i
o
n
l
a
b
e
l
o
r
s
e
p
a
r
a
t
o
r
(
s
e
e
F
i
g
u
r
e
1
6
)
.
U
s
e
s
l
i
s
t
t
e
x
t
f
o
r
e
n
t
r
y
i
n
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
\
c
a
p
t
i
o
n
o
f
{
o
a
t
t
y
p
e
}
[
l
i
s
t
e
n
t
r
y
]
{
c
a
p
t
i
o
n
t
e
x
t
}
I
f
o
a
t
t
y
p
e
i
s
f
i
g
u
r
e
t
h
e
n
F
i
g
u
r
e
c
a
p
t
i
o
n
a
n
d
e
n
t
r
y
i
n
L
i
s
t
o
f
F
i
g
u
r
e
s
i
s
g
e
n
e
r
-
a
t
e
d
,
e
v
e
n
i
f
t
h
e
\
c
a
p
t
i
o
n
o
f
c
o
m
m
a
n
d
i
s
l
o
c
a
t
e
d
o
u
t
s
i
d
e
o
f
a
g
u
r
e
e
n
v
i
r
o
n
m
e
n
t
.
L
i
k
e
w
i
s
e
,
i
f
o
a
t
t
y
p
e
i
s
t
a
b
l
e
t
h
e
n
F
i
g
u
r
e
c
a
p
t
i
o
n
a
n
d
e
n
t
r
y
i
n
L
i
s
t
o
f
T
a
b
l
e
i
s
g
e
n
e
r
a
t
e
d
,
e
v
e
n
i
f
t
h
e
\
c
a
p
t
i
o
n
o
f
c
o
m
m
a
n
d
i
s
l
o
c
a
t
e
d
o
u
t
s
i
d
e
o
f
a
t
a
b
l
e
e
n
v
i
r
o
n
-
m
e
n
t
.
\
c
a
p
t
i
o
n
o
f
*
{
o
a
t
t
y
p
e
}
{
c
a
p
t
i
o
n
t
e
x
t
}
S
i
m
i
l
a
r
t
o
\
c
a
p
t
i
o
n
o
f
c
o
m
m
a
n
d
,
t
h
e
o
a
t
t
y
p
e
s
p
e
c
i
e
s
w
h
e
t
h
e
r
a
g
u
r
e
o
r
t
a
b
l
e
c
a
p
t
i
o
n
i
s
g
e
n
e
r
a
t
e
d
.
S
i
m
i
l
a
r
t
o
\
c
a
p
t
i
o
n
*
c
o
m
m
a
n
d
,
\
c
a
p
t
i
o
n
o
f
*
c
o
m
m
a
n
d
u
s
e
s
c
a
p
t
i
o
n
t
e
x
t
f
o
r
g
u
r
e
/
t
a
b
l
e
c
a
p
t
i
o
n
b
u
t
d
o
e
s
n
o
t
i
n
c
l
u
d
e
c
a
p
t
i
o
n
l
a
b
e
l
o
r
s
e
p
a
r
a
t
o
r
(
s
e
e
F
i
g
u
r
e
1
6
)
.
N
o
e
n
t
r
y
i
s
g
e
n
e
r
a
t
e
d
f
o
r
t
h
e
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
\
c
a
p
t
i
o
n
o
f
*
{
o
a
t
t
y
p
e
}
[
l
i
s
t
e
n
t
r
y
]
{
c
a
p
t
i
o
n
t
e
x
t
}
W
h
e
n
o
p
t
i
o
n
a
l
[
l
i
s
t
e
n
t
r
y
]
i
s
s
p
e
c
i
e
d
,
t
h
e
\
c
a
p
t
i
o
n
o
f
*
c
o
m
m
a
n
d
u
s
e
s
l
i
s
t
e
n
t
r
y
f
o
r
e
n
t
r
y
i
n
L
i
s
t
o
f
F
i
g
u
r
e
s
/
T
a
b
l
e
s
.
\
C
o
n
t
i
n
u
e
d
F
l
o
a
t
A
l
l
o
w
s
m
u
l
t
i
p
l
e
\
c
a
p
t
i
o
n
c
o
m
m
a
n
d
t
o
s
h
a
r
e
s
a
m
e
g
u
r
e
n
u
m
b
e
r
.
S
e
e
S
e
c
t
i
o
n
3
2
.
3
o
n
P
a
g
e
1
1
5
a
n
d
S
e
c
t
i
o
n
3
3
o
n
P
a
g
e
1
1
5
.
71
causes all subsequent caption in the current environment to be indented by an
additional 10pt on both left and right sides, with the entire caption (label and
text) having a small font size and the label having a bold font series.
Table 13 describes the \captionsetup and \clearcaptionsetup commands.
The \captionsetup command has two advantages over specifying options in the
\usepackage command
The \captionsetup command has optional arguments that cause the options
to apply to just gures or just tables.
The \captionsetup can change the settings for an individual gure or table.
For example:
\begin{figure}
...
\captionsetup{centering}
\caption{This is the Caption Text}
\end{figure}
causes the captions to be centered for this gure only but does not aect any
other gure.
While the \captionsetup can be used to customize a single caption, this is generally
considered bad style. In general, a user should issue \captionsetup commands the
preamble and avoid using \captionsetup within the document.
72
Table 13: Caption Setup Commands from Caption Package
Command Description
\captionsetup[oat type]{options} Set caption attributes
Examples \captionsetup{options} options apply to all captions
\captionsetup[figure]{options} options apply only to gure captions
\captionsetup[table]{options} options apply only to table captions
\clearcaptionsetup{oat type} changes caption attributes to defaults
Examples \clearcaptionsetup{figure} resets gure captions to have default options
\clearcaptionsetup{table} resets table captions to have default options
Table 14: Font Options
Option Aected portion
font= Aects entire caption (caption label, separa-
tor, and caption text).
labelfont= Aects only caption label and separator
textfont= Aects only caption text
Table 15: Possible Font Option Values
Action Option Value Description
Use all font defaults default Changes font family, shape, series, and
size to defaults
Specify font family rm roman font family (default)
sf san sarif font family
tt typewriter font family
Specify font shape up upright font shape (default)
it italic font shape
sl slanted font shape
sc small caps font shape
Specify font series md medium font series (default)
bf bold font series
Specify font size scriptsize scriptsize font size
footnotesize footnotesize font size
small small font size
normalsize normal font size (default)
large large font size
Large Large font size
73
Table 16: captionsetup Vertical Space Options
Keyword Value Description
aboveskip= <amount> (default is 10pt) Sets the vertical spacing between the cap-
tion and the gure/table contents. Normally, this space is
placed above the caption, but when position=top then the
aboveskip= spacing is placed below the caption.
belowskip= <amount> (default is 0pt) Sets the vertical spacing in the direction away
from the gure/table contents. Normally, this space is placed
below the caption, but when position=top then belowskip=
spacing is placed above the caption.
position= bottom (default) Places the aboveskip= spacing above the caption
and the belowskip= spacing below the caption.
top This caption reverses the aboveskip= and belowskip= spac-
ings (to accommodate captions at the top of oats).
parskip= <amount> (default is 0pt) The amount of vertical space inserted between
a captions paragraphs. (This option has no eect on captions
with only one paragraph).
Table 17: captionsetup Label and Separator Options
Keyword Value Description
labelformat= default (default) Caption label is typeset as specied in the document
class.
simple The caption label is typeset as a name and a number. For
example Figure 9.
parens The number is typeset inside parentheses. For example, (9).
empty The caption label is empty (no Figure, no number). This is
usually used with labelsep=none to also eliminate the cap-
tion separator.
labelsep= colon (default) The caption separator is a colon and a space
period The caption separator is a period and a space
space The caption separator is a single space
quad The caption separator is a \quad
newline The caption separator is a \newline
none No caption separator. Usually used only with
labelformat=empty
74
Table 18: captionsetup Formatting Options
Keyword Value Description
format= default (default) Captions are typeset as normal paragraphs.
hang The captions 2nd and subsequent lines are indented. It gener-
ally causes the rst character of the 2nd line to be horizontally
aligned with the rst character of the caption text on the rst
line.
justification= justified (default) Caption is typeset as a regular paragraph.
centerlast Last line of caption is horizontally centered.
centerfirst First line of caption is horizontally centered.
centering Each line of caption is horizontally centered.
Centering Same as centering except the T
E
X word-breaking algorithm
is used.
raggedright Each line is left-justied, leaving a ragged right margin.
RaggedRight Same as raggedright except the T
E
X word-breaking algo-
rithm is used.
raggedleft Each line is right-justied, leaving a ragged left margin.
RaggedLeft Same as raggedleft except the T
E
X word-breaking algorithm
is used.
indentation= <amount> (default is 0pt) Amount of additional indentation for the cap-
tions 2nd and subsequent lines.
hangindent= <amount> (default is 0pt) Amount of additional indentation for the
2nd and subsequent lines of each paragraph in a caption.
Note hangindent= does not apply to the rst line of each
paragraph. (If a caption contains only one paragraph, then
hangindent= and indentation= are equivalent.)
margin= <amount> (default is 0pt) Both left and right margins are brought in by
specied amount.
width= <amount> Sets caption width (left and right margins are brought in equal
amounts). If both margin= and width= values are specied,
the last option specied applies.
singlelinecheck= true (default) If the caption ts on a single line, then the caption
is centered regardless of justification= value.
false Format of justification= is applied to single line captions.
75
20.4 Caption Package Examples
20.4.1 Caption Package Font Options
Table 14 shows the three options the caption package provides for customizing a
captions fonts, where label, separator, caption text are dened in Figure 16
on Page 76. These three options can change any combination of font family, shape,
series, and size, as shown in Table 15.
Figure 14
Caption
Label
:
S
e
p
a
r
a
t
o
r
Plot of Temperature vs. Time
Caption
Text
Figure 16: Denition of Caption Label, Separator, Text
Font Example #1
The command
\captionsetup{font={default,Large,bf}}
...
\caption{This is Caption Font Example \#1}
sets all caption font characteristics to their defaults, then gives entire gure caption
(label, separator, and caption text) Large font size and bold font series, as shown in
Figure 17. The font family and shape remain set to their defaults.
Graphic
Figure 17: This is Caption Font Example #1
Note that the above example aects both gure and table captions. Adding a
[figures] optional argument to the \captionsetup command
\captionsetup[figures]{font={default,Large,bf}}
causes only the gure captions to be modied.
Font Example #2
The command
\captionsetup{font=default, textfont={scriptsize,sf}}
...
\caption{This is Caption Font Example \#2}
76
sets all gure-caption font characteristics to their defaults, then gives the caption
text scriptsize font size and san serif font family, as shown in Figure 18.
Graphic
Figure 18: This is Caption Font Example #2
Font Example #3
The command
\captionsetup{font={default,Large}, labelfont=bf, textfont=sl}
...
\caption{This is Caption Font Example \#3}
sets all gure-caption font characteristics to their defaults, then gives the entire cap-
tion (label, separator, and caption text) Large font size, gives only the caption label
and separator bold font series, and gives only the caption text slanted font shape, as
shown in Figure 19.
Graphic
Figure 19: This is Caption Font Example #3
20.4.2 Caption Vertical Package Spacing Options
As their names suggest, the space above the caption is specied by the aboveskip
option while the space below the caption is specied by the belowskip option. How-
ever, this is only the case when the default position=bottom option is used. The
position=top option reverses the meanings of the aboveskip and belowskip op-
tions. It can get confusing if the user has customized aboveskip and belowskip for
a top-caption and then wants a bottom caption, in which case the position=top
option would have to be used to produce a bottom caption.
To avoid confusion, the following procedure should be used
1. Think of aboveskip= option as the caption/oat spacing. That is, the space be-
tween the caption and the oat contents should be specied in the aboveskip=
option.
2. Think of belowskip= option as the caption/text spacing. That is, the space be-
tween the caption and the surrounding text should be specied in the belowskip=
option.
3. Use position=bottom for captions at the bottom of oats. Use position=top
for captions at the top of oats.
77
Caption Vertical Spacing Example #1
The aboveskip= option modies the spacing above a caption (the default spacing is
10pt). The following code
\captionsetup{aboveskip=1cm}
...
\caption{Vertical Spacing Example \#1}
causes produces a 1cm spacing above the caption as shown in Figure 20.
Graphic
Figure 20: Vertical Spacing Example #1
Caption Vertical Spacing Example #2
The previous example showed how the aboveskip= option modies the spacing above
a caption. This example shows how the position=top reverses the meaning of
aboveskip and belowskip.
The following code
\captionsetup{aboveskip=1cm,position=top}
...
\caption{Vertical Spacing Example \#2}
causes produces a 1cm spacing below the caption as shown in Table 19
Table 19: Vertical Spacing Example #2
a b
c d
Caption Vertical Spacing Example #3
The previous example showed the position=top reverses the meaning of aboveskip
and belowskip for use in placing a caption above tables.
If table captions will be placed above the table while most gure captions will
be placed below the gure, it is convenient to make the top position the default for
table captions
\captionsetup{aboveskip=1cm,belowskip=0pt}
\captionsetup[figure]{position=bottom}
\captionsetup[table]{position=top}
...
\caption{Table for Vertical Spacing Example \#3}
\caption{Figure for Vertical Spacing Example \#3}
78
causes produces a 1cm spacing below table captions (as shown in Table 20) and a
1cm spacing above gure captions (as shown in Figure 21).
Table 20: Table for Vertical Spacing Example #3
a b
c d
Graphic
Figure 21: Figure for Vertical Spacing Example #3
20.4.3 Caption Package Label Options
Caption Label Example #1
The following code
\captionsetup{labelformat=simple}
...
\caption{This is Caption Label Example \#1}
dene the label format to be simple, as shown in Figure 22. The simple format is
usually the same as the default, although the document class could dene default
dierently.
Graphic
Figure 22: This is Caption Label Example #1
Caption Label Example #2
The following code
\captionsetup{labelformat=parens}
...
\caption{This is Caption Label Example \#2}
dene the label format to be parens, as shown in Figure 23. This format has no
Figure name, and instead just has the gure number surrounded by parentheses.
Graphic
Figure (23): This is Caption Label Example #2
79
Caption Label Example #3
The following code
\captionsetup{labelformat=empty, labelsep=none}
...
\caption{This is Caption Label Example \#3}
dene the label format to be empty, as shown in Figure 23. Since no gure number
is displayed, it is dicult to determine that it is Figure 23.
Graphic
This is Caption Label Example #3
Caption Label Example #4
The following code
\captionsetup{labelformat=default, labelsep=period}
...
\caption{This is Caption Label Example \#4}
changes the caption separator from the default colon to a period, as shown in Fig-
ure 25.
Graphic
Figure 25. This is Caption Label Example #4
Caption Label Example #5
The following code
\captionsetup{labelformat=default, labelsep=newline}
...
\caption{This is Caption Label Example \#5}
changes the caption separator to a newline, as shown in Figure 25.
Graphic
Figure 26
This is Caption Label Example #5
80
20.4.4 Caption Package Formatting Options
Formatting Example #1: Caption Width
The following code
\captionsetup{width=3in}
...
\caption{This is an example of customizing the caption width}
causes the caption to be typeset in a 3-inch wide column, as shown in Figure 27.
Graphic
Figure 27: This is an example of customizing
the caption width
Formatting Example #2: Default Format
Figure 28 - Figure 36 on Page 82 show examples of the seven possible justification=
values used with format=default. These gures are produced by the following code
\captionsetup{format=default,justification=justified}
\caption{Caption with default format and justified justification.
Caption with default format and justified justification.
Caption with default format and justified justification.}
...
\captionsetup{format=default,justification=centering}
\caption{Caption with default format and centering justification.
Caption with default format and centering justification.
Caption with default format and centering justification.}
...
\captionsetup{format=default,justification=centerlast}
\caption{Caption with default format and centerlast justification.
Caption with default format and centerlast justification.
Caption with default format and centerlast justification.}
...
\captionsetup{format=default,justification=centerfirst}
\caption{Caption with default format and centerfirst justification.
Caption with default format and centerfirst justification.
Caption with default format and centerfirst justification.}
...
\captionsetup{format=default,justification=raggedright}
\caption{Caption with default format and raggedright justification.
Caption with default format and raggedright justification.
Caption with default format and raggedright justification.}
...
\captionsetup{format=default,justification=RaggedRight}
\caption{Caption with default format and RaggedRight justification.
Caption with default format and RaggedRight justification.
Caption with default format and RaggedRight justification.}
...
\captionsetup{format=default,justification=raggedleft}
\caption{Caption with default format and raggedleft justification.
Caption with default format and raggedleft justification.
Caption with default format and raggedleft justification.}
81
Graphic
Figure 28: Caption with default format and jus-
tied justication. Caption with default format
and justied justication. Caption with default
format and justied justication.
Graphic
Figure 29: Caption with default format and cen-
terlast justication. Caption with default for-
mat and centerlast justication. Caption with
default format and centerlast justication.
Graphic
Figure 30: Caption with default format and
centerrst justication. Caption with default
format and centerrst justication. Caption
with default format and centerrst justication.
Graphic
Figure 31: Caption with default format and
centering justication. Caption with default
format and centering justication. Caption
with default format and centering justication.
Graphic
Figure 32: Caption with default for-
mat and Centering justication. Cap-
tion with default format and Center-
ing justication. Caption with default
format and Centering justication.
Graphic
Figure 33: Caption with default format and
raggedright justication. Caption with default
format and raggedright justication. Caption
with default format and raggedright
justication.
Graphic
Figure 34: Caption with default format and
RaggedRight justication. Caption with de-
fault format and RaggedRight justication.
Caption with default format and RaggedRight
justication.
Graphic
Figure 35: Caption with default format and
raggedleft justication. Caption with default
format and raggedleft justication. Caption
with default format and raggedleft
justication.
Graphic
Figure 36: Caption with default for-
mat and RaggedLeft justication. Cap-
tion with default format and RaggedLeft
justication. Caption with default
format and RaggedLeft justication.
82
As can be seen in Figure 28 - Figure 36, the above code causes the rst line of the
caption to be formatted the same as all of the other lines.
Formatting Example #3: Hang Format
The previous example used the format=default option. This previous example
creates Figure 37 - Figure 45, showing the seven possible justification= values
used with format=hang. These gures are produced by the following code
\captionsetup{format=hang,indention=0pt,justification=justified}
\caption{Caption with hang format and justified justification.
Caption with hang format and justified justification.
Caption with hang format and justified justification.}
...
\captionsetup{format=hang,indention=0pt,justification=centering}
\caption{Caption with hang format and centering justification.
Caption with hang format and centering justification.
Caption with hang format and centering justification.}
...
\captionsetup{format=hang,indention=0pt,justification=centerlast}
\caption{Caption with hang format and centerlast justification.
Caption with hang format and centerlast justification.
Caption with hang format and centerlast justification.}
...
\captionsetup{format=hang,indention=0pt,justification=centerfirst}
\caption{Caption with hang format and centerfirst justification.
Caption with hang format and centerfirst justification.
Caption with hang format and centerfirst justification.}
...
\captionsetup{format=hang,indention=0pt,justification=raggedright}
\caption{Caption with hang format and raggedright justification.
Caption with hang format and raggedright justification.
Caption with hang format and raggedright justification.}
...
\captionsetup{format=hang,indention=0pt,justification=RaggedRight}
\caption{Caption with hang format and RaggedRight justification.
Caption with hang format and RaggedRight justification.
Caption with hang format and RaggedRight justification.}
...
\captionsetup{format=hang,indention=0pt,justification=raggedleft}
\caption{Caption with hang format and raggedleft justification.
Caption with hang format and raggedleft justification.
Caption with hang format and raggedleft justification.}
As can be seen in Figure 37 - Figure 45, the format=hang option in the above code
causes the second and subsequent lines to have additional indentation.
20.5 Further Customization
The caption has additional feature for users who want additional customization. This
section provides a brief description, with detailed instruction available in [11].
20.5.1 Caption Styles
Users can dene a collection of caption options, called caption styles. The entire
collection of options can be specied with a single option. For example, the caption
package automatically denes a style named default such that
\captionsetup{style=default}
is equivalent to
83
Graphic
Figure 37: Caption with hang format and jus-
tied justication. Caption with
hang format and justied justica-
tion. Caption with hang format and
justied justication.
Graphic
Figure 38: Caption with hang format and cen-
terlast justication. Caption with
hang format and centerlast justica-
tion. Caption with hang format and
centerlast justication.
Graphic
Figure 39: Caption with hang format
and centerrst justication. Caption
with hang format and centerrst
justication. Caption with hang
format and centerrst justication.
Graphic
Figure 40: Caption with hang format and
centering justication. Caption
with hang format and centering
justication. Caption with hang
format and centering justication.
Graphic
Figure 41: Caption with hang format and
Centering justication. Caption
with hang format and Centering
justication. Caption with hang
format and Centering justication.
Graphic
Figure 42: Caption with hang format and
raggedright justication. Caption
with hang format and raggedright
justication. Caption with hang
format and raggedright
justication.
Graphic
Figure 43: Caption with hang format and
RaggedRight justication. Caption
with hang format and RaggedRight
justication. Caption with hang
format and RaggedRight justica-
tion.
Graphic
Figure 44: Caption with hang format and
raggedleft justication. Caption
with hang format and raggedleft
justication. Caption with hang
format and raggedleft justication.
Graphic
Figure 45: Caption with hang format
and RaggedLeft justica-
tion. Caption with hang for-
mat and RaggedLeft justica-
tion. Caption with hang format
and RaggedLeft justication.
84
\captionsetup{font=default, labelfont=default,
textfont=default, aboveskip=10pt,
belowskip=0pt, position=bottom,
parskip=0pt, labelformat=simple,
labelsep=colon, format=default,
indentation=0pt, hangindent=0pt,
margin=0pt, parinident=0pt,
justification=justified,
singlelinecheck=true}
The \DeclareCaptionStyle can be used in the document preamble to dene other
caption styles. These styles can either explicitly dene all of the parameters or start
with the default style and modify only the unique option values.
For example, the following \DeclareCaptionStyle command in the documents
preamble
\DeclareCaptionStyle{BigLeft}{style=default,labelsep=period,
font=Large,labelfont=bold,
justification=RaggedRight,singlelinecheck=false}
allows the BigLeft style to be referenced by
\captionsetup{style=BigLeft}
...
\caption{This Caption uses BigLeft Style}
as shown in Figure 46.
Graphic
Figure 46
This Caption uses BigLeft Style
20.5.2 Additional Option Values
The caption package provides commands such as
\DeclareCaptionFont
\DeclareCaptionLabelSeparator
\DeclareCaptionLabelFormat
\DeclareCaptionFormat
\DeclareCaptionLabelJustification
to provide additional option values. These commands can only be issued in the
documents preamble.
Option Denition Example #1
Table 15 on Page 73 denes the possible font options that can be used by the
font=, labelfont=, and textfont= options. The \DeclareCaptionFont allows the
user to dene additional values that can be used by these options. For example, the
following command in the documents preamble
\DeclareCaptionFont{BigAndBold}{\Large\bfseries}
denes a BigAndBold font such that the following code
85
\captionsetup{font=BigAndBold}
...
\caption{This Caption uses a Custom Font}
produces the caption in Figure 47
Graphic
Figure 47: This Caption uses a Custom Font
Option Denition Example #2
Table 17 on Page 74 describes how the labelformat= option controls how the Figure
33 portion of the caption is displayed. The \DeclareCaptionLabelFormat allows
the user to dene additional labelformat= options. The symbols #1 and #2 are used
in the denition to specify where the Figure and Figure Number are inserted. For
example the following command in the documents preamble
\DeclareCaptionLabelFormat{hash}{#1 {\#}#2}
denes a hash formatting option such that a hash mark # is placed between just
before the gure number. However, this denition has a aw in that the space
in the denition after #1 is not desired should #1 be empty. The \bothIfFirst
command typesets both of its arguments if the rst argument exists, otherwise neither
argument is typeset. Similarly, the \bothIfSecond command typesets both of its
arguments if the second argument exists, otherwise neither argument is typeset. The
new denition using \bothIfFirst is
\DeclareCaptionLabelFormat{hash}{\bothIfFirst{#1}{ }{\#}#2}
This denition, when placed in the documents preamble allows the following code
\captionsetup{labelformat=hash}
...
\caption{This Caption has a Custom Label Format}
to produce the caption in Figure 48.
Graphic
Figure #48: This Caption has a Custom Label Format
Option Denition Example #3
Table 17 on Page 74 denes the possible values for the labelset= option. The
\DeclareCaptionLabelSeparator command allows users to dene additional values
for the labelset= option. For example, the following command in the documents
preamble
\DeclareCaptionLabelSeparator{arrow}{\quad\ensuremath{\Rightarrow}\quad}
denes an arrow label separator such that the following code
\captionsetup{labelsep=arrow}
...
\caption{This Caption has a Custom Label Separator}
86
produce the caption in Figure 49.
Graphic
Figure 49 This Caption has a Custom Label Separator
Option Denition Example #4
Table 18 on Page 75 species the values that can be used by the format= option.
The \DeclareCaptionFormat command allows users to dene additional values for
the format= option.
The symbols #1, #2, #3 are used in the denition to specify where the various
building blocks appear, where #1 represent the caption label, #2 represents the cap-
tion separator, and #3 represents the caption text (where these terms are dened
in Figure 16 on Page 76). For example, the following command in the documents
preamble
\DeclareCaptionFormat{reverse}{#3#2\ensuremath{\ll}#1\ensuremath{\gg}}
denes the reverse format with the caption text appearing rst, followed by the
separator, and then the caption label surrounded by double angle brackets \ll and
\gg. The following code
\captionsetup{format=reverse,labelsep=empty}
...
\caption{This Caption has a Custom Format}
produces the caption in Figure 50.
Graphic
This Caption has a Custom Format
Figure 50
21 Non-Floating Figures
Since non-oating gures can produce large sections of vertical whitespace, non-
oating gures are generally considered poor typesetting style. Instead, users are
strongly encouraged to use the gure environments [!ht] optional argument which
moves the gure only if there is not enough room for it on the current page.
As described in Section 17, L
A
T
E
X allows gures and tables to oat to improve
the documents formatting. Occasionally, it is desirable to have a gure appear
exactly where it appears in the L
A
T
E
X source. Although the \caption command
can only be used figure and table environments, the caption package denes the
\captionof command which takes two arguments: the type of caption (table, gure,
etc) and the caption text, allowing the \captionof command can be used outside of
gure and table environments. Using
\figureof{figure}{caption text}
creates a gure caption, regardless of whether it appears in a gure environment.
Likewise,
87
\figureof{table}{caption text}
creates a table caption, regardless of its location. The following commands
This is the text before the figure.
\\[\intextsep]
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=2in]{graphic}%
\captionof{figure}{This is a non-floating figure}
\label{fig:non:float}
\end{minipage}
\\[\intextsep]
This is the text after the figure.
create a non-oating gure. Notes on non-oating gures:
The minipage environment is needed to prevent a page break within the gure.
The \\[\intextsep] commands start new lines and add vertical space before
and after the gure. Any amount of space can be used, \intextsep (see
Section 19.1 on Page 64) was used to make the non-oating gure spacing
consistent with oating gure spacing.
Normally, gures are placed on the page in the same order they were submitted
to the gure queue. However, non-oating gures are placed immediately,
leapfrogging any unprocessed gures sitting in the gure queue. If this happens,
the gures do not appear in numerical order
32
. To avoid these out-of-order
gures, force all oating gures to be processed by issuing a \clearpage or
\FloatBarrier command before the non-oating gure (see Section 17.3 on
Page 59).
The \figureof command is also useful for creating marginal gures (Section 22
on Page 89), and creating a table beside a gure (Section 30 on Page 109).
21.1 Non-oating Figures without the caption package
As described above, the caption packages \captionof command creates captions
outside of gure/table environments. This section describes how to do this without
using the caption package.
The \caption command can be used in figure and table environments because
these environments dene the internal command \@captype to gure and table,
respectively. By dening \@captype, the \caption command can be used outside of
gure and table environments. A \makeatletter\makeatother pair must enclose
\@captype to allow @ to be used in a command name. While this can be done
manually each time by
\includegraphics{file}
\makeatletter\def\@captype{figure}\makeatother
\caption{This is the caption}
it is easier to dene a command to do this. Including the following commands in the
documents preamble
\makeatletter
\newcommand\figcaption{\def\@captype{figure}\caption}
\newcommand\tabcaption{\def\@captype{table}\caption}
\makeatother
32
In these situations, the Table of Figures lists the gures in order of appearance, not in numerical
order.
88
denes the \figcaption and \tabcaption commands. Using \figcaption creates
gure captions, regardless of whether it appears in a gure environment. Likewise,
\tabcaption creates table caption, regardless of it location.
21.2 The oat Packages [H] Placement Option
The oat package
33
adds an [H] option to the figure environment which produces a
non-oating gure. The following code
\usepackage{float}
...
\begin{figure}[H]
.....
\end{figure}
produces a non-oating gure.
When the [H] gure does not t on a page, the gure is moved to the top of the
next page. If there were any footnotes on the rst page, they appear immediately
after the text instead of at the bottom of the page. If this behavior is undesirable,
then the \captionof command described in Section 21 on Page 87 can be used
instead of the oat packages [H] placement option.
22 Marginal Figures
The \marginpar command places notes in the margin of the document. The marginal
notes are placed in the right margin (or the outside margin for twoside documents)
unless the \reversemarginpar command is used (as it is in this document). The
width of the marginal column is controlled by the \marginparwidth length, while
the horizontal spacing between the text and the marginal notes is controlled by the
\marginparsep length.
Marginal notes are placed such that the baseline of their rst line is vertically
aligned with the baseline of the text which contains the \marginpar command.
Marginal notes are never broken across a page; if a marginal note starts near the
bottom of the page, it continues into the bottom margin. If the previous marginal
note would interfere with a marginal note, L
A
T
E
X bumps the latter marginal note
downward. Marginal notes cannot be bumped to the next page; they are instead
bumped into the bottom margin. As a result, the position of the marginal notes
may have to be adjusted before the nal printing to avoid marginal notes near page
breaks.
Since the figure environment cannot be used in a marginal note, oating mar-
ginal gures are not possible. However, the \captionof command dened in Sec-
tion 21 on Page 87 can be used to construct a non-oating marginal gure. For
Graphic
Figure 51: This
is a Marginal
Figure
example, Figure 51 was produced by
...to construct a non-floating marginal figure.
\marginpar{\centering
\includegraphics[width=\marginparwidth]{graphic}%
\captionof{figure}{This is a Marginal Figure}
\label{fig:marginal:fig} }
For example, \Figref{fig:marginal:fig} was...
33
The oat package allows users to dene new types of oats, such as Program or Algorithm.
It also denes optional boxed and ruled oat styles. These optional oat styles redene the \caption
command such that the caption is always typeset at a particular location, regardless of where the
\caption command is located, preventing construction of side-by-side and other complex gures.
89
The bottom of the graphic in Figure 51 is aligned with the text baseline where the
\marginpar command is located. Notes on marginal gures:
Since captions for marginal gures generally are narrow, using the caption com-
mands \captionstyle{flushleft} or \captionstyle{flushright} before
the \caption command may provide better caption formatting. Additionally,
the caption command
\renewcommand{\captionfont}{\small}
can be used to decrease the size of the caption font. See Section 20 on Page 69
for caption information.
Like the non-oating gures in Section 21 on Page 87, the marginal gures are
placed ahead of any unprocessed oats. Thus, a \clearpage or \FloatBarrier
command must be issued before the marginal note if one wants to keep the
gures in order.
Marginal notes are placed by the routine which also places gures and tables.
If many gures, tables, and marginal notes are being used, it is possible to
exceed the number of unprocessed oats permitted by L
A
T
E
X. The moreoats
package can mitigate these problems (see Section 17.4 on Page 60).
23 Wide Figures
Typesetting readability rules limit the number of characters in a line of text. Unless
a large font or two columns are used, these readability rules result in wide margins
(especially when using 8.5 x 11 inch letter paper). Section 22 demonstrated how
these wide margins can be used for marginal gures. Another option is to construct
a regular oating gure which extends into one or both margins. This is done by
placing a wide list environment inside the gure. For example, a narrow environment
can be dened by including the following code in the preamble of your document
\newenvironment{narrow}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}}%
\item[]}{\end{list}}
For example, any text which occurs between \begin{narrow}{1in}{2in} is indented
by 1 inch on the left side and 2 inches on the right side. When negative lengths are
used, the contents extend beyond the margins.
23.1 Wide Figures in One-sided Documents
The following code uses this narrow environment to make the gure extend 1 inch
into the left margin, producing Figure 52.
\begin{figure}
\begin{narrow}{-1in}{0in}
\includegraphics[width=\linewidth]{wide}
\caption{This is a wide figure}
\end{narrow}
\end{figure}
90
A Very, Very Wide Graphic
Figure 52: This is a wide gure
When marginal notes are used, it may be desired to make the wide gure extend
exactly to the edge of the marginal notes (making the gure width be \linewidth
+ \marginparwidth + \marginparsep). This can be done by dening a new length
\marginwidth and setting it to be \marginparwidth + \marginparsep. For exam-
ple,
\newlength{\marginwidth}
\setlength{\marginwidth}{\marginparwidth}
\addtolength{\marginwidth}{\marginparsep}
then use {-\marginwidth} in the \begin{narrow} argument.
23.2 Wide Figures in Two-sided Documents
For two-sided documents, it may be desired to extend the wide gures into the
binding-side margin (i.e., the left margin for odd pages and the right margin for even
pages). In these cases, the ifthen packages \ifthenelse command can be used to
choose between odd-page code and even-page code. For example,
\usepackage{ifthen}
...
\begin{figure}
\ifthenelse{\isodd{\pageref{fig:wide}}}%
{% BEGIN ODD-PAGE FIGURE
\begin{narrow}{0in}{-1in}
\includegraphics[width=\linewidth]{file}
\caption{Figure Caption}
\label{fig:wide}
\end{narrow}
}% END ODD-PAGE FIGURE
{% BEGIN EVEN-PAGE FIGURE
\begin{narrow}{-1in}{0in}
\includegraphics[width=\linewidth]{file}
\caption{Figure Caption}
\label{fig:wide}
\end{narrow}
}% END EVEN-PAGE FIGURE
\end{figure}
Since the \pageref command is used as input to \ifthenelse, the gure may not
be properly typeset until L
A
T
E
X is run enough times to cause the cross-references to
converge.
24 Landscape Figures
In a document with portrait orientation, there are three methods for producing
gures with landscape orientation.
1. The lscape package provides a landscape environment, which treats the left
edge of the paper as the top of the page, causing any text, tables, or gures in
the landscape environment to have landscape orientation.
91
2. The rotating package provides a sidewaysfigure environment which is similar
to the figure environment except that the gures have landscape orientation.
3. The rotating package provides a \rotcaption command which is similar to the
\caption command except that caption has landscape orientation.
Dierences between methods
Both options 1 and 2 place the landscape gure on a separate page. Option 3
produces an individual oat which need not be on its own page.
While Option 2 produces only rotated gures, the landscape environment
in Option 1 is a general-purpose environment, which can produce landscape
pages containing any combination of text, tables, and gures. The landscape
environment can page-breaking capability, so multiple landscape pages can be
produced
34
.
The full-page gure produced by Option 2 oats to provide better document
formatting, while the gure produced by Option 1 cannot oat
35
.
Since Options 1 and 3 use the figure environment, they can be used in con-
junction with the endoat package (see Section 19.6 on Page 68).
Options 1 and 2 are best suited for side-by-side landscape graphics (for side-
by-side methods see Section 28 on Page 104).
24.1 Landscape Environment
The lscape package (which is part of the standard graphics bundle distributed
with L
A
T
E
X) denes the landscape environment, which provides a method of placing
landscape pages in a portrait document. The landscape pages are rotated such that
the left edge of the portrait page is the top edge of the landscape page.
Entering \begin{landscape} prints all unprocessed portrait oats and then
switches to landscape orientation. Likewise, \end{landscape} prints all unprocessed
landscape oats and then switches back to portrait orientation.
The entire contents of the landscape environment is typeset with landscape ori-
entation. This may include any mixture of text, gures, and tables. If the landscape
environment contains only a gure environment
\begin{landscape}
\begin{figure}
\centering
\includegraphics[width=4in]{graphic}
\caption{Landscape Figure}
\end{figure}
\end{landscape}
the landscape environment produces a landscape gure. Note that since the landscape
environment starts a new page, it may result in a partially-blank page.
34
The landscape environment works very well with the longtable package to produce multiple-page
landscape tables.
35
Figures issued in the landscape environment can oat within the landscape pages
92
24.2 Sidewaysgure Environment
The rotating package provides the sidewaysfigure environment which produces g-
ures with landscape orientation
36
. For example
\begin{sidewaysfigure}
\centering
\includegraphics[width=4in]{graphic}
\caption{Sidewaysfigure Figure}
\end{sidewaysfigure}
produces Figure 53.
Unlike the landscape environment, the gure produced by sidewaysfigure can
oat within the portrait pages to avoid the partially-blank page that the landscape
environment may produce. Note that the landscape environment is much more
exible, allowing the landscape pages to consist of a mixture of text, tables, and
gures.
The default orientation of the gures produced by sidewaysfigure depends on
whether the document is processed with the oneside or twoside documentclass
option
When the oneside option is chosen, the bottom of graphic is towards the right
edge of the portrait page.
When the twoside option is chosen, the bottom of graphic is towards the
outside edge of the portrait page.
This default behavior can be overridden by options to the \usepackage{rotating}
command.
\usepackage[figuresleft]{rotating}
causes the bottom of the sidewaysfigure graphics to be towards the left edge of
the portrait page (regardless of oneside or twoside options). Similarly,
\usepackage[figuresright]{rotating}
causes the bottom of the sidewaysfigure graphics to be towards the right edge of
the portrait page.
24.3 Rotcaption Command
The methods in Sections 24.1 and 24.2 both produce full-page landscape gures,
which may not be necessary for smaller landscape gures. The rotating packages
\rotcaption command can be used to construct smaller landscape gures. For
example
\begin{figure}
\centering
\begin{minipage}[c]{1in}
\hfill\includegraphics[width=2in,angle=90]{graphic}
\end{minipage}%
\hspace{0.2in}%
\begin{minipage}[c]{0.5in}
\captionsetup{width=2in}
\rotcaption{This is a caption created by the Rotcaption command}
\label{fig:rotcaption}
\end{minipage}
\end{figure}
93
G
r
a
p
h
i
c
F
i
g
u
r
e
5
3
:
S
i
d
e
w
a
y
s
g
u
r
e
F
i
g
u
r
e
94
G
r
a
p
h
i
c
F
i
g
u
r
e
5
4
:
T
h
i
s
i
s
a
c
a
p
t
i
o
n
c
r
e
a
t
e
d
b
y
t
h
e
R
o
t
c
a
p
t
i
o
n
c
o
m
m
a
n
d
produces Figure 54.
The caption produced by \rotcaption is always rotated such that its bot-
tom is towards the right edge of the paper. Unlike the methods in Sections 24.1
and 24.2, the \rotcaption command does not rotate the graphics. Therefore, the
\includegraphics command in the above example requires the angle=90 option.
25 Captions Beside Figures
Although the caption of a gure is generally placed above or below the graphic, this
section describes how to place the caption beside the graphic
37
.
25.1 The Sidecap Package
The easiest way of constructing side captions is to use the sidecap package. When
a \caption command is used in the SCgure and SCtable environments dened by
the sidecap package, the captions are automatically placed to the side of the contents
of the environment. For example,
\usepackage{sidecap}
...
\begin{SCfigure}
\includegraphics[width=3in]{graphic}
\caption{This is a SCfigure}
\end{SCfigure}
produces Figure 55.
The following four options can be specied in the \usepackage command
outercaption This option places the caption to the left for left (even) pages and
on the right for right (odd) pages. (This is the default)
36
The rotating package also provides a sidewaystable environment for producing tables with
landscape orientation.
37
Since the gure environment dened by the oat package places the caption below the body,
captions beside gures cannot be produced with the oat packages gure environment. Other
aspects of the oat package can be used as long as the \restylefloat command is not issued.
95
Graphic
Figure 55: This is a SCgure
innercaption This option places the caption to the right for left (even) pages and
on the left for right (odd) pages.
leftcaption This option places the caption on the left.
rightcaption This option places the caption on the right.
The SCfigure environment includes two optional arguments
The rst optional argument species the relative width of caption compared to
the gure. A large value (e.g., 100) reserves the maximum possible width. The
default is 1.
The second optional argument species the oat position parameter (e.g. [htp]
or [!ht] (see Section 17.2 on Page 58).
25.2 Side Captions without Sidecap
If the sidecap package does not provide sucient exibility, users can produce side
captions with the methods in this section. Section 25.2.1 shows how to place the
caption to the left of the graphic. Placing the caption to the right of the graphic
proceeds similarly. For twoside documents, Section 25.2.2 shows how to place the
caption to the inside of the graphic (to the left of the graphic for odd pages and to
the right of the graphic for even pages).
25.2.1 Caption to Left of Figure
The \caption command places the caption under the gure or table. Minipage
environments can be used to trick the caption command into placing the caption
beside the gure. For example, the commands
\begin{figure}
\centering
\begin{minipage}[c]{.45\linewidth}
\centering
\caption{Caption on the Side}
\label{fig:side:caption}
\end{minipage}%
\begin{minipage}[c]{.45\linewidth}
\centering
\includegraphics[width=\linewidth]{graphic}
\end{minipage}
\end{figure}
produces Figure 56. It may be desirable to place a horizontal spacing command such
as \hfill or \hspace{.05\linewidth} between the minipages.
The caption and graphic in Figure 56 are centered vertically. If it is instead
desired to align the bottoms or tops of graphics and caption, see Section 11.4 on
Page 36.
96
Figure 56: Caption on the Side
Graphic
25.2.2 Caption on Binding Side of Graphic
The above code for Figure 56 places the caption to the left of the graphic. For two-
sided documents, it may be desired to place the caption on the binding side of the
graphics. In these cases, the ifthen packages \ifthenelse command can be used to
choose between odd-page code and even-page code. For example,
\usepackage{ifthen}
...
\begin{figure}
\centering
\ifthenelse{\isodd{\pageref{fig:side:caption}}}
{% BEGIN ODD-PAGE FIGURE
\begin{minipage}[c]{.45\linewidth}
\centering
\caption{Caption on the Side}
\label{fig:side:caption}
\end{minipage}%
\hspace{0.05\linewidth}%
\begin{minipage}[c]{.45\linewidth}
\includegraphics[width=\linewidth]{graphic}
\end{minipage}%
}% END ODD-PAGE FIGURE
{% BEGIN EVEN-PAGE FIGURE
\begin{minipage}[c]{.45\linewidth}
\includegraphics[width=\linewidth]{graphic}
\end{minipage}%
\hspace{0.05\linewidth}%
\begin{minipage}[c]{.45\linewidth}
\centering
\caption{Caption on the Side}
\label{fig:side:caption}
\end{minipage}%
}% END EVEN-PAGE FIGURE
\end{figure}
produces a gure where the caption always appear on the binding side of the graphic.
26 Figures on Even or Odd Pages
The gure environment oat-placement algorithm does not control whether a gure
appears on an even or odd page. This section describes how to use the \afterpage
command (part of the afterpage package) and the \ifthenelse command (part of
the ifthen package) to place a gure onto an odd or even page.
The conventional method for creating gures is to put the graphics in a gure
environment. However, since gure environments can oat, there is no guarantee
that a gure desired for an even-page wont end up on an odd page (or vice versa).
Instead, the \captionof command described in Section 21 can be used to create
a gure without using a gure environment. The \ifthenelse command is then
used to place the rst graphic on the next even page. This requires repeating the
graphics commands twice, once for the case of the next page being odd and once for
the case of the next page being even. To simplify the resulting code, a \leftfig
command is dened
97
\newcommand\leftfig{%
\vspace*{\fill}%
\centering
\includegraphics{graphic}
\captionof{figure}{This is on the left (even) page.}
\vspace*{\fill}\newpage}
The left-page gures are then created using this newly-dened \leftfig command
along with the \afterpage and \ifthenelse commands
\afterpage{\clearpage%
\ifthenelse{\isodd{\value{page}}}%
{\afterpage{\leftfig}}%
{\leftfig}}
Notes about odd/even page placement:
To force the gure to a right-hand (odd) page, reverse the order of the \ifthenelse
arguments.
\afterpage{\clearpage%
\ifthenelse{\isodd{\value{page}}}%
{\leftfig}}%
{\afterpage{\leftfig}}
Because these are non-oating gures, the \value{page} command can be
used to determine the current page. (This is not useful for oating gures since
\value{page} is the current page when the gure environment is processed,
not where it is placed.) Thus using \value{page} is better than \pageref
since \pageref is only correct once the L
A
T
E
X references have converged).
When using large gures, it is possible for a pagebreak to occur within the
gure (e.g., between the graphic and the caption). The gure can be forced to
stay together by enclosing it in a minipage environment
\newcommand\leftfig{%
\vspace*{\fill}%
\begin{minipage}{\linewidth}
\centering
\includegraphics{graphic}
\captionof{figure}{This is on the left (even) page.}
\end{minipage}
\vspace*{\fill}\newpage}
The \afterpage command can sometimes be aky, in rare cases causing a lost
oat error. Removing the \clearpage before the \ifthenelse may help this
situation.
\afterpage{\ifthenelse{\isodd{\value{page}}}%
{\afterpage{\leftfig}}%
{\leftfig}}
In the above example, the gure uses the entire even page. To place the gure at
the top of the even page, modify or remove the \vspace*{\fill} and \newpage
commands
\newcommand\leftfig{%
\centering
\includegraphics{graphic}
\captionof{figure}{This is at the top of the left (even) page.}
\vspace{\floatsep}}
98
26.1 Figures on Facing Pages
To ease the comparison of two gures in a twoside document, it may be desirable to
position the gures on facing pages. To do this, a procedure similar to the previous
sections even/odd page-placement must be used. To simplify the resulting code, a
\facingfigures command is dened as
\newcommand\facingfigures{%
\vspace*{\fill}%
\centering
\includegraphics{left}
\captionof{figure}{This is on the left (even) page.}
\vspace*{\fill}\newpage\vspace*{\fill}%
\centering
\includegraphics{right}
\captionof{figure}{This is on the right (odd) page.}
\vspace*{\fill}\newpage}
The facing gures are then created using this \facingfigures command along with
the \afterpage and \ifthenelse commands
\afterpage{\clearpage%
\ifthenelse{\isodd{\value{page}}}%
{\afterpage{\facingfigures}}%
{\facingfigures}}
27 Boxed Figures
The term Boxed Figure usually refers to one of two situations
A box surrounds the gures graphic but not the gures caption.
A box surrounds the gures graphic and its caption.
The basic method for boxing an item is to simply place the item inside an \fbox
command, which surrounds the object with a rectangular box. The fancybox package
provides boxes of dierent styles.
27.1 Box Around Graphic
Placing an \fbox command around the \includegraphics command produces a
box around the included graphic. For example, the commands
\begin{figure}
\centering
\fbox{\includegraphics[totalheight=2in]{file}}
\caption{Box Around Graphic, But Not Around Caption}
\label{fig:boxed_graphic}
\end{figure}
place a box around the included gure, as shown in Figure 57.
27.2 Box Around Figure and Caption
To include both the gures graphic and its caption, one may be tempted to move
the \caption command inside the \fbox command. However, this does not work
because \caption can only be used in paragraph mode, while the contents of an
\fbox command are processed in LR mode
38
.
38
L
A
T
E
X uses three modes: LR mode, paragraph mode, and math mode. See [1, pages 36,103-5].
99
L1
N
P1
q1
q2
L2
P2
Figure 57: Box Around Graphic, But Not Around Caption
Since the contents of minipage environments and \parbox commands are processed
in paragraph mode, the \caption command can be included in the \fbox by enclos-
ing the \fbox contents inside a minipage environment or a \parbox command. Since
both minipages and parboxes require a width specication, there is no direct way to
make the \fbox exactly as wide the graphic and caption.
For example, the commands
\begin{figure}
\centering
\fbox{ \begin{minipage}{4 in}
\centering
\includegraphics[totalheight=2in]{pend}
\caption{Box Around Figure Graphic and Caption}
\label{fig:boxed_figure}
\end{minipage} }
\end{figure}
place a box around the gures graphic and caption, as shown in Figure 58
L1
N
P1
q1
q2
L2
P2
Figure 58: Box Around Figure Graphic and Caption
It is usually a trial-and-error process to determine a minipage width which causes
the box to have a snug t around the caption and graphic. This trial-and-error can
be avoided by the following approaches.
1. Choose an arbitrary minipage width and force the graphic to be as wide as the
minipage
100
\includegraphics[width=\linewidth]{pend}
2. When it is desired to specify the graphic height, the proper minipage width
can be calculated by placing the graphic in a box and measuring the height of
the box.
\newsavebox{\mybox}
\newlength{\mylength}
\sbox{\mybox}{\includegraphics[height=3in]{file}}
\settowidth{\mylength}{\usebox{\mybox}}
\begin{figure}
\centering
\fbox{ \begin{minipage}{\mylength}
\centering
\usebox{\mybox}
\caption{Box Around Figure Graphic and Caption}
\label{fig:boxed_figure}
\end{minipage} }
\end{figure}
3. To ensure a one-line caption, the minipage can be made as wide as the caption
by estimating the caption width with a \settowidth command
\newlength{\mylength}
\settowidth{\mylength}{Figure XX: Box Around Figure Graphic and Caption}
\fbox{ \begin{minipage}{\mylength}
...
27.3 Customizing fbox Parameters
In Figures 57 and 58, the box is constructed of 0.4 pt thick lines with a 3 pt space
between the box and the graphic. These two dimensions can be customized by
setting the L
A
T
E
X length variables \fboxrule and \fboxsep, respectively, with the
\setlength command. For example, the commands
\begin{figure}
\centering
\setlength{\fboxrule}{3pt}
\setlength{\fboxsep}{1cm}
\fbox{\includegraphics[totalheight=2in]{pend}}
\caption{Graphic with Customized Box}
\label{fig:boxed_custom}
\end{figure}
place a box with 3 pt thick lines which is separated from the graphic by 1 centimeter,
as shown in Figure 59
101
L1
N
P1
q1
q2
L2
P2
Figure 59: Graphic with Customized Box
27.4 The Fancybox Package
In Figures 57, 58, and 59, the \fbox command was used to place standard rec-
tangular boxes around the gures. The fancybox package provides four commands
\shadowbox, \doublebox, \ovalbox, and \Ovalbox which produce other types of
boxes.
Table 21: FancyBox Commands
Command Parameters
\shadowbox{Example}
Example
The frame thickness is \fboxrule.
The shadow thickness is \shadowsize (which defaults to 4 pt).
\doublebox{Example}
Example
The inner frame thickness is .75\fboxrule
The outer frame thickness is 1.5\fboxrule
The spacing between the frames is 1.5\fboxrule + 0.5pt.
\ovalbox{Example}
Example
The frame thickness is \thinlines
Entering \cornersize{x} the diameter of the corners x times the
minimum of the width and the height. The default is 0.5.
The \cornersize* command directly sets the corner diameter. For
example, \cornersize*{1cm} makes the corner diameters 1 cm.
\Ovalbox{Example}
Example
\Ovalbox is the same as \ovalbox except that the line thickness is
controlled by \thicklines.
102
Like \fbox, the separation between these boxes and their contents is controlled
by the L
A
T
E
X length \fboxsep. The length \shadowsize is set with the \setlength
command, as was done for \fboxrule and \fboxsep in Section 27.3 on Page 101.
The lines for \ovalbox and \Ovalbox have thicknesses corresponding to the picture
environments \thicklines and \thinlines, which are not lengths and thus can-
not be changed with the \setlength command. The values of \thicklines and
\thinlines depend on the size and style of the current font. Typical values are
0.8 pt for \thicklines and 0.4 pt for \thinlines. For example, the commands
\begin{figure}
\centering
\shadowbox{ \begin{minipage}{3.5 in}
\centering
\includegraphics[totalheight=2in]{pend}
\caption{Shadowbox Around Entire Figure}
\label{fig:boxed_fancy}
\end{minipage} }
\end{figure}
place a shadow box around the gures graphic and caption, as shown in Figure 60.
L1
N
P1
q1
q2
L2
P2
Figure 60: Shadowbox Around Entire Figure
103
Part V
Complex Figures
28 Side-by-Side Graphics
The commands necessary for side-by-side graphics depend on how the user wants
the graphics organized. This section covers three common groupings of side-by-side
graphics
1. The side-by-side graphics are combined into a single gure.
2. The side-by-side graphics each form their own gure (e.g., Figure 63 and Fig-
ure 64).
3. The side-by-side graphics each form a subgure (e.g., Subgure 65a and Sub-
gure 65b) which are part of a single gure (Figure 65).
This section describes the following two methods for constructing the three types of
groupings
a) Successive \includegraphics commands.
b) Side-by-side minipages, each of which contains an \includegraphics com-
mand.
It is very important to understand the material in Section 2 on Page 10 when con-
structing side-by-side gures. Side-by-side gures are created by placing boxes (either
\includegraphics or minipages) beside each other on a line.
28.1 Side-by-Side Graphics in a Single Figure
The easiest method for creating side-by-side graphics in a single gure is successive
\includegraphics commands, although using side-by-side minipages makes it easier
to vertically align the graphics.
28.1.1 Using Side-by-Side includegraphics Commands
The following code
\begin{figure}
\centering
\includegraphics[width=1in]{graphic}%
\hspace{1in}%
\includegraphics[width=2in]{graphic}
\caption{Two Graphics in One Figure}
\end{figure}
produces Figure 61 which is 4 inches wide (1 inch for the rst graphic, 1 inch for
the \hspace, and 2 inches for the second graphic) which is centered on the page.
The \hspace command can be omitted or replaced with \hfill, which pushes the
graphics to the margins (see Section 10.2 on Page 32).
28.1.2 Using Side-by-Side Minipages
Placing the \includegraphics commands inside minipage environments provides
the user more control over the graphics vertical placement. For example
104
Graphic
Graphic
Figure 61: Two Graphics in One Figure
\begin{figure}
\centering
\begin{minipage}[c]{0.5\linewidth}
\centering \includegraphics[width=1in]{graphic}
\end{minipage}%
\begin{minipage}[c]{0.5\linewidth}
\centering \includegraphics[width=2in]{graphic}
\end{minipage}
\caption{Centers Aligned Vertically}
\end{figure}
produces Figure 62, which has vertically-centered graphics.
Graphic
Graphic
Figure 62: Centers Aligned Vertically
Notes on this example:
Like any other L
A
T
E
X object, minipages are positioned such that their reference
point is aligned with the current baseline. By default, minipages use the [c]
option which places the reference point at the vertical center of the minipage,
the [t] option places the reference point at the baseline of the minipages
top line and the [b] option places the reference point at the baseline of the
minipages bottom line (see Section 11.4 on Page 36).
The % after the rst \end{minipage} command prevents an interword space
from being inserted between the minipage boxes (see Section 10.2 on Page 32).
When the widths of the minipages do not add to 1.0\linewidth, the \hspace
or \hfill commands can be used to specify horizontal spacing (see Section 10.2
on Page 32).
28.2 Side-by-Side Figures
In the previous section, multiple minipage environments were used inside a figure
environment to produce a single gure consisting of multiple graphics. Placing
\caption statements inside the minipages makes the minipages themselves become
gures. For example
\begin{figure}
\centering
%%----start of first figure----
\begin{minipage}[t]{0.4\linewidth}
\centering
\includegraphics[width=1in]{graphic}
105
\caption{Small Box} \label{fig:side:a}
\end{minipage}%
\hspace{1cm}%
%%----start of second figure----
\begin{minipage}[t]{0.4\linewidth}
\centering
\includegraphics[width=1.5in]{graphic}
\caption{Big Box} \label{fig:side:b}
\end{minipage}
\end{figure}
produces Figures 63 and 64.
Graphic
Figure 63: Small Box
Graphic
Figure 64: Big Box
Notes about this example:
Although the above commands include one gure environment, the commands
produce two gures because two \caption commands are used.
The gures are put inside two minipages whose widths are 40% of the width of
the gure environment that are separated by 1cm of horizontal space. (Note
that comment characters after \end{minipage} and \hspace{1cm} ensure that
the spacing is exactly 1cm by preventing interword spaces between the mini-
pages and the horizontal space.)
By default, the gure captions are typeset to the entire width of the minipage.
The 1cm of horizontal space was used to ensure horizontal spacing between the
captions (for longer captions and/or wider graphics).
Alternatively, the caption widths could be limited by the caption packages
margin or width keywords (see Table 18 on Page 75).
The \centering command immediately after \begin{figure} causes the group
of two minipages and spacing to be centered in the gure environment.
The \centering command inside the minipage causes the graphics to be cen-
tered within the minipage.
28.3 Side-by-Side Subgures
It may be desirable to refer to side-by-side graphics both individually and as a
group. The \subfloat command (from the subg package, described in Section 32
on Page 112) allows a group of graphics to be individually dened as subgures that
are dened to be part of a single gure. For example
\usepackage{subfig}
...
\begin{figure}
\centering
%%----start of first subfigure----
\subfloat[Small Box with a Long Caption]{
\label{fig:subfig:a} %% label for first subfigure
\includegraphics[width=1.0in]{graphic}}
\hspace{1in}
%%----start of second subfigure----
\subfloat[Big Box]{
106
\label{fig:subfig:b} %% label for second subfigure
\includegraphics[width=1.5in]{graphic}}
\caption{Two Subfigures}
\label{fig:subfig} %% label for entire figure
\end{figure}
produces Figure 65. The commands used to individually and collectively reference
the parts of Figure 65 are shown in Table 22.
Graphic
(a) Small Box with
a Long Caption
Graphic
(b) Big Box
Figure 65: Two Subgures
Table 22: Subgure Reference Commands and Their Output for Figure 65 Example
Reference Command Output
\subref{fig:subfig:a} (a)
\subref*{fig:subfig:a} a
\ref{fig:subfig:a} 65a
\subref{fig:subfig:b} (b)
\subref*{fig:subfig:b} b
\ref{fig:subfig:b} 65b
\ref{fig:subfig} 65
28.3.1 Minipage Environments Inside Subgures
Since Subgure 65a consists of only the \includegraphics command, the caption
in subgure 65a is only as wide as the included graphic. If the subgure instead
consists of the entire minipage, the caption is made as wide as the minipage. For
example
\begin{figure}
\subfloat[Small Box with a Long Caption]{
\label{fig:mini:subfig:a} %% label for first subfigure
\begin{minipage}[b]{0.45\linewidth}
\centering \includegraphics[width=1in]{graphic}
\end{minipage}}%
\hfill
\subfloat[Big Box]{
\label{fig:mini:subfig:b} %% label for second subfigure
\begin{minipage}[b]{0.45\linewidth}
\centering \includegraphics[width=1.5in]{graphic}
\end{minipage}}
\caption{Minipages Inside Subfigures}
\label{fig:mini:subfig} %% label for entire figure
\end{figure}
produces Figure 66, which contains subgures 66a and 66b.
Since subgure captions are (by default) as wide as the subgure, the subgure
captions in Figure 66 are wider than those in Figure 65. This is because the Figure 65
subgures contain only the graphics while the Figure 66 subgures contain minipages
of width 0.5\linewidth.
107
Graphic
(a) Small Box with a Long Caption
Graphic
(b) Big Box
Figure 66: Minipages Inside Subgures
29 Separate Minipages for Captions
Section 28.2 on Page 105 described how to construct side-by-side gures by placing
the graphics command and \caption command together inside a minipage envi-
ronment. This section describes how placing the graphics command and \caption
command in separate minipage environments can provide better vertical alignment.
The [t] options for the side-by-side minipages in Figures 63 and 64 cause the
graphic baselines to be aligned (see Section 11.4 on Page 36). This works well for
non-rotated graphics as it causes the tops of the captions to be aligned. However,
this does not work well when the graphics bottoms are not aligned. For example,
\begin{figure}
\centering
%%----start of first figure----
\begin{minipage}[t]{.4\linewidth}
\centering
\includegraphics[width=2cm]{graphic}
\caption{Box with a Long Caption}
\end{minipage}%
\hspace{1cm}%
%%----start of second figure----
\begin{minipage}[t]{.4\linewidth}
\centering
\includegraphics[width=2cm,angle=-30]{graphic}
\caption{Rotated Box}
\end{minipage}%
\end{figure}
produces Figures 67 and 68 which do not have their captions aligned. The [b]
minipage options would not completely solve the problem, as it causes the bottom
lines of the caption to be aligned.
Graphic
Figure 67: Box with a Long Cap-
tion
G
r
a
p
h
i
c
Figure 68: Rotated Box
The alignment of the graphics and the captions can be done separately by creating
two rows of minipages: the rst row containing the gures and the second row
containing the captions. For example
\begin{figure}
\centering
%%----start of first figure graphics----
\begin{minipage}[b]{.4\linewidth}
\centering
\includegraphics[width=2cm]{graphic}
\end{minipage}%
\hspace{1cm}%
108
%%----start of second figure graphics----
\begin{minipage}[b]{.4\linewidth}
\centering
\includegraphics[width=2cm,angle=-30]{graphic}
\end{minipage}\\[-10pt]
%%----start of first figure caption----
\begin{minipage}[t]{.4\linewidth}
\caption{Box with a Long Caption}
\end{minipage}%
\hspace{1cm}%
%%----start of second figure caption----
\begin{minipage}[t]{.4\linewidth}
\caption{Rotated Box}
\end{minipage}%
\end{figure}
produces Figures 69 and 70, which have the graphic baselines aligned and the caption
top lines aligned.
Graphic
G
r
a
p
h
i
c
Figure 69: Box with a Long Cap-
tion
Figure 70: Rotated Box
Notes on this example
The \\ breaks the line after the last gure. The \\ optional argument [-10pt]
moves the captions closer to the graphics by removing 10 points of vertical space
at the linebreak. This length should be changed as the user see t.
The graphic minipages have a [b] option to make their reference points be the
baseline of the minipages bottom line.
The caption minipages have a [t] option to make their reference points be the
baseline of the minipages top line (to vertically-align the captions top lines).
Any \label commands must be issued in the same minipage as the correspond-
ing \caption command.
30 Placing a Table Beside a Figure
In Section 28 on Page 104, side-by-side gures are constructed by using multiple
\caption commands in a single gure environment. Likewise, side-by-side tables are
created by using multiple \caption commands in a single table environment.
The \captionof commands described in Section 21 on Page 87 make it possible
to put a table beside a gure. For example, the following commands
\begin{figure}[htb]
\begin{minipage}[b]{0.5\linewidth}
\centering
\includegraphics[width=0.8\linewidth]{graphic}
\caption{This is a Figure by a Table}
\label{fig:by:table}
\end{minipage}%
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{tabular}{|c|c|} \hline
109
Day & Data \\ \hline\hline
Monday & 14.6 \\
Tuesday & 14.3 \\
Wednesday & 14.2 \\
Thursday & 14.5 \\
Friday & 14.9 \\ \hline
\end{tabular}
\captionof{table}{This is a Table by a Figure}
\label{table:by:fig}
\end{minipage}
\end{figure}
use a gure environment to create Figure 71 and Table 23.
Graphic
Figure 71: This is a Figure by a Table
Day Data
Monday 14.6
Tuesday 14.3
Wednesday 14.2
Thursday 14.5
Friday 14.9
Table 23: This is a Table by a Figure
Since L
A
T
E
X allows gure oats to leapfrog table oats, using \captionof{table}{...}
in a gure environment may place the table ahead of unprocessed tables. Like-
wise, using \captionof{figure}{...} in a table environment may place the g-
ure ahead of unprocessed gures. If this is objectionable, it can be prevented by
putting a \FloatBarrier command before the gure environment (see Section 17.3
on Page 59).
31 Stacked Figures and Subgures
Side-by-side gures are created in Section 28 on Page 104 by a variety methods, all of
which involve placing objects (graphics, minipages, suboats) next to each other on a
single line. The same procedure produces stacked graphics when the \\ command is
used to explicitly add a linebreak. The \\ commands optional argument can specify
additional vertical space, such as \\[20pt].
31.1 Stacked Figures
Section 28 explained how to construct side-by-side gures. This section shows that
adding a linebreak produces multiple rows of gures. For example, the following code
\begin{figure}[htbp]
\centering
%%----start of first figure----
\begin{minipage}[t]{0.25\linewidth}
\centering
\includegraphics[width=\linewidth]{graphic}
\caption{First Stacked Figure}
\label{fig:stacked:first}
\end{minipage}%
\hspace{1cm}%
%%----start of second figure----
\begin{minipage}[t]{0.25\linewidth}
\centering
110
\includegraphics[width=\linewidth]{graphic}
\caption{Second Stacked Figure}
\label{fig:stacked:second}
\end{minipage}\\[20pt]
%%----start of third figure----
\begin{minipage}[t]{0.25\linewidth}
\centering
\includegraphics[width=\linewidth]{graphic}
\caption{Third Stacked Figure}
\label{fig:stacked:third}
\end{minipage}%
\hspace{1cm}%
%%----start of fourth figure----
\begin{minipage}[t]{0.25\linewidth}
\centering
\includegraphics[width=\linewidth]{graphic}
\caption{Fourth Stacked Figure}
\label{fig:stacked:fourth}
\end{minipage}%
\hspace{1cm}%
%%----start of fifth figure----
\begin{minipage}[t]{0.25\linewidth}
\centering
\includegraphics[width=\linewidth]{graphic}
\caption{Fifth Stacked Figure}
\label{fig:stacked:fifth}
\end{minipage}%
\end{figure}
produces Figures 72-76.
Graphic
Figure 72: First
Stacked Figure
Graphic
Figure 73: Second
Stacked Figure
Graphic
Figure 74: Third
Stacked Figure
Graphic
Figure 75: Fourth
Stacked Figure
Graphic
Figure 76: Fifth
Stacked Figure
31.2 Stacked Subgures
Section 28.3 on Page 106 explained how to construct side-by-side subgures. This
section shows how adding a linebreak produces rows of subgures. For example, the
following code
\begin{figure}
\centering
%%----start of first subfigure----
\subfloat[First Subfigure]{
\label{fig:stacksub:a} %% label for first subfigure
\includegraphics[width=0.25\linewidth]{graphic}}
\hspace{0.1\linewidth}
%%----start of second subfigure----
111
\subfloat[Second Subfigure]{
\label{fig:stacksub:b} %% label for second subfigure
\includegraphics[width=0.25\linewidth]{graphic}}\\[20pt]
%%----start of third subfigure----
\subfloat[Third Subfigure]{
\label{fig:stacksub:c} %% label for third subfigure
\includegraphics[width=0.25\linewidth]{graphic}}
\hspace{0.1\linewidth}
%%----start of fourth subfigure----
\subfloat[Fourth Subfigure]{
\label{fig:stacksub:d} %% label for fourth subfigure
\includegraphics[width=0.25\linewidth]{graphic}}
\hspace{0.1\linewidth}
%%----start of fifth subfigure----
\subfloat[Fifth Subfigure]{
\label{fig:stacksub:e} %% label for fifth subfigure
\includegraphics[width=0.25\linewidth]{graphic}}
\caption{Five Subfigures}
\label{fig:stacksub} %% label for entire figure
\end{figure}
produces Figure 77.
Graphic
(a) First Subgure
Graphic
(b) Second Subgure
Graphic
(c) Third Subgure
Graphic
(d) Fourth Subgure
Graphic
(e) Fifth Subgure
Figure 77: Five Subgures
32 The subg package
This section provides an overview of the subg package. Readers are encouraged to
read Steven Douglas Cochrans subg documentation [30] for the full details
39
.
Section 28.3 provided an example that used the subg packages \subfloat com-
mand to create subgures. The example also used the \label command to dene
labels for the gure and the individual subgures. This labels can be referenced using
the \ref command and the subg packages \subref and \subref* commands, with
referencing examples described Table 22.
32.1 The Suboat Command
The \subfloat command has one mandatory argument and two optional arguments.
The mandatory argument contains the commands (such as \includegraphics) that
39
Since the subg package requires the caption package, some of subg packages capability comes
from the caption code. Fortunately, the subg documentation describes the full subg capability,
regardless of where the corresponding code resides.
112
generate the subgure contents. The two optional arguments aect the subgures
caption:
If no optional arguments are specied then the subgure has no subcaption
If one optional argument is specied, its contents provide the subgures sub-
caption and its list-of-gures text.
If two optional arguments are specied, the rst (left) optional argument pro-
vides the subgures list-of-gure text while the second (right) optional argu-
ment provides its subcaption.
More detail on on the \subfloat command options are given in Table 24.
32.2 Customizing subg with captionsetup Command
Section 20.1 on Page 69 describes how Figure caption can be customized using the op-
tional caption package. The same customization can be applied to subgure captions
created by the subg package
40
.
The \captionsetup command has an optional argument which species whether
the customization applies to gures, subgures, tables, subtables, or some combi-
nation. Table 25 shows the possible \captionsetup optional arguments and their
eects.
In addition to the \captionsetup commands options listed on Page 73 - 75, there
are some \captionsetup options which apply only to the subg package, as shown
in Table 26.
40
Since the subg package automatically includes the caption package, the subg always has all of
the caption packages customization capabilities.
Table 24: \subfloat calling arguments
Command List-of-Figures Caption Sub-oat caption
\subfloat{body}
\subfloat[ ]{body} (b) (b)
\subfloat[caption text]{body} (c) caption text (c) caption text
\subfloat[ ][caption text]{body} (d) caption text
\subfloat[ ][ ]{body} (e)
\subfloat[list text][caption text]{body} (f) list text (f) caption text
\subfloat[list text][ ]{body} (g) list text (g)
Table 25: subg packages \captionsetup options
Command Description
\captionsetup{options} options apply to all captions
\captionsetup[figure]{options} options apply only to gures and subgure captions
\captionsetup[table]{options} options apply only to table and subtable captions
\captionsetup[subfloat]{options} options apply only to all suboats (subgures and sub-
tables)
\captionsetup[subfigure]{options} options apply to subgures
\captionsetup[subtable]{options} options apply to subtables
113
Table 26: subg captionsetup Options
Keyword Values Default Description
config= <filename> subfig.cfg The lename from which to load subg congu-
ration.
lofdepth= <integer> 1 If lofdepth=1, then only Figures are included in
the List of Figures. If lofdepth=2, then both
Figures and Subgures are included in the List
of Figures.
lotdepth= <integer> 1 If lotdepth=1, then only Tables are included in
the List of Tables. If lotdepth=2, then both
Tables and Subtables are included in the List of
Tables.
listofindent= <length> 3.8em Sets the total indentation from the left margin
for List of Floats line for suboats.
listofnumwidth= <length> 2.5em Sets the width of box for the label number for
List of Floats line for suboats.
farskip= <length> 10pt Vertical space on the far side of the suboat
(on the side away from the main caption).
nearskip= <length> 0pt Vertical space on the near side of the suboat
(on the side towards the main caption).
captionskip= <length> 4pt Vertical space between the suboat and its sub-
caption
topadjust= <length> 0pt Extra vertical space added to captionskip when
subcaption is above suboat.
listofformat= (see
Table 27)
subparens Species format of entries in List of Figures
and List of Tables. Must be specied before
\listoffigures
subrefformat= (see
Table 27)
subsimple Species format of \subref* output. Format of
\subref* output depends on the subrefformat=
value when the suboat is formed, regardless of
the subrefformat= value when the \subref*
command is entered.
Table 27: subg captionsetup Options for listofformat= and subrefformat=
Values Example Description
subsimple b Only output subgure letter.
subparens (b) Output subgure letter surrounded by parens.
empty Dont output anything.
simple 17b Output gure number and subgure letter.
parens 17(b) Output gure number followed by subgure
letter surrounded by parens.
114
32.3 The ContinuedFloat Command
The subg package also provides the \ContinuedFloat command which allows sub-
gures to be split between multiple gure environments (and thus multiple pages).
This is useful when
a gure has too many subgures to t on a single page
or when an author wishes to relate multiple full-page graphics by having them
numbered (17a, 17b, 17c) instead (18, 19, 20)
Examples of the \ContinuedFloat are provided in Section 33.
33 Continued Figures and Subgures
When two successive gures contain closely-related material, it may be desirable to
label the gures with the same gure number. Since the figure counter contains the
number of the next gure, two gures can be given the same number by decrementing
the figure counter before the gure environment. For example,
\begin{figure}
....
\end{figure}
\addtocounter{figure}{-1}
\begin{figure}
....
\end{figure}
However, the inability to distinguish between these identically-numbered gures
causes confusion.
33.1 Continued Figures
The best way of constructing a continued gure is to use the subgure package to
create multiple Figures, each of which contains a single subgure. This allows the
continued gures to be referenced individually as Figure 12(a) or collectively Fig-
ure 12.
\begin{figure}[tbp]
\centering
\subfloat[Subcaption for First Part]{
\label{subfig:continued:first} %% label for first part
... figure contents ... }
\caption{Example of Continued Figure}
\label{fig:continued:first}
\end{figure}
\begin{figure}[tbp]
\centering
\subfloat[Caption for Second Part]{
\label{subfig:continued:second} %% label for second part
... figure contents ... }
\caption{Example of Continued Figure}
\label{fig:continued:second}
\end{figure}
115
Graphic
(a) First Subgure
Graphic
(b) Second Subgure
Figure 78: Two Subgures
33.2 Continued Subgures
When grouping subgures together in a gure, there often is not enough room to
place all of the subgures on a single page. Instead of breaking them into two
dierently-numbered Figures, the \ContinuedFloat command allows the two sets of
subgures to have the same Figure number. For example, the following code
\begin{figure}
\centering
%%----start of first subfigure----
\subfloat[First Subfigure]{
\label{fig:contfig:subone} %% label for first subfigure
\includegraphics[width=3cm]{graphic}}
\hspace{1cm}
%%----start of second subfigure----
\subfloat[Second Subfigure]{
\label{fig:contfig:subtwo} %% label for second subfigure
\includegraphics[width=3cm]{graphic}}
\caption{Two Subfigures}
\label{fig:contfig:one} %% label for first part
\end{figure}
....
\begin{figure}
\ContinuedFloat
\centering
%%----start of third subfigure----
\subfloat[Third Subfigure]{
\label{fig:contfig:subthree} %% label for third subfigure
\includegraphics[width=3cm]{graphic}}
\hspace{1cm}
%%----start of fourth subfigure----
\subfloat[Fourth Subfigure]{
\label{fig:contfig:subfour} %% label for fourth subfigure
\includegraphics[width=3cm]{graphic}}
\caption{Two Additional Subfigures}
\label{fig:contfig:two} %% label for second part
\end{figure}
Creates one oat that contains Figures 78a and 78b and another oat that contains
Figures 78c and 78d. Note that the \ContinuedFloat command not only gives
the oats the same Figure number, it also ensures that the second oats subgure
lettering does not reset to (a).
Graphic
(c) Third Subgure
Graphic
(d) Fourth Subgure
Figure 78: Two Additional Subgures
Table 28 shows the values created by the \ref and \pageref commands for this
continued-gure example. The two captions have dierent labels ({fig:contfig:one}
116
and {fig:contfig:two}) which both produce the same \ref value of 78, but since
the two oat are on dierent pages, the two labels produce dierent \pageref values,
as shown in Table 28.
Since four subgures could easily t in one oat, this example obviously does
not require the \ContinuedFloat command. But this example is meant to show the
procedure for larger collections of subgures.
Table 28: Subgure Ref and Pageref Commands and Their Output for the Figure 78
Example
Reference Command Output
Figure \ref{fig:contfig:one} Figure 78
Page \pageref{fig:contfig:one} Page 116
Figure \ref{fig:contfig:two} Figure 78
Page \pageref{fig:contfig:two} Page 116
117
References
[1] Leslie Lamport, L
A
T
E
X: A Document Preparation System, Second Edition,
Addison-Wesley, Reading, Massachusetts, 1994, ISBN 0-201-52983-1
[2] Helmut Kopka and Patrick Daly, A Guide to L
A
T
E
X, Fourth Edition,
Addison-Wesley, Reading, Massachusetts, 2004, ISBN 0-321-17385-6
[3] Frank Mittelbach and Michel Goossens, with Johannes Braams, David Carlisle,
and Chris Rowley, The L
A
T
E
X Companion, Second Edition, Addison-Wesley
Pearson Education, Boston, Massachusetts, 2004, ISBN 0-201-36299-6
[4] Michel Goossens, Sebastian Rahtz, and Frank Mittelbach, The L
A
T
E
X Graphics
Companion, Addison-Wesley, Reading, Massachusetts, 1997,
ISBN 0-201-85469-4
[5] Michel Goossens, Sebastian Rahtz, and Frank Mittelbach, The L
A
T
E
X Web
Companion, Addison-Wesley, Reading, Massachusetts, 1999,
ISBN 0-201-43311-7
[6] D. P. Carlisle, Packages in the graphics bundle (Documents the graphics,
graphicx, lscape, color packages), Available as
CTAN/macros/latex/required/graphics/grfguide.ps
[7] Tobias Oetiker, The Not So Short Introduction to L
A
T
E
X2
Available at
CTAN/info/lshort/english/lshort.pdf and
CTAN/info/lshort/english/lshort.ps
[8] Harvey Greenberg, A Simplied Introduction to L
A
T
E
X Available at
CTAN/info/simplified-latex/simplified-intro.ps
[9] David Carlisle, The afterpage package, Available as
CTAN/macros/latex/required/tools/afterpage.dtx
[10] L
A
T
E
X3 Project Team, The calc package, Available as
CTAN/macros/latex/required/tools/calc.dtx
[11] Axel Sommerfeldt, Typesetting captions with the caption package, Available as
CTAN/macros/latex/contrib/caption/caption.pdf
[12] Peter R. Wilson, The ccaption package, Available as
CTAN/macros/latex/contrib/ccaption/ccaption.pdf
[13] James Darrell McCauley and Je Goldberg, The endoat Package, Available
as CTAN/macros/latex/contrib/endfloat/endfloat.pdf
[14] Rolf Niepraschk The eso-pic package, Available as
CTAN/macros/latex/contrib/eso-pic/eso-pic.pdf
[15] Timothy Van Zandt, Documentation for fancybox.sty, Available as
CTAN/macros/latex/contrib/fancybox/fancybox.doc
[16] Piet van Oostrum, Page layout in L
A
T
E
X, Available as
CTAN/macros/latex/contrib/fancyhdr/fancyhdr.pdf
[17] The after package, Available as CTAN/macros/latex/unpacked/flafter.sty
118
[18] Anselm Lingnau, An Improved Environment for Floats, Available as
CTAN/macros/latex/contrib/float/float.dtx
[19] Sebastian Rahtz and Heiko Oberdiek Hypertext marks in L
A
T
E
X: a manual for
hyperref, Available as
CTAN/macros/latex/contrib/hyperref/doc/manual.pdf
[20] Heiko Oberdiek The ifpdf package, Available as
CTAN/macros/latex/contrib/oberdiek/ifpdf.sty
[21] David Carlisle, The ifthen package, Available as
CTAN/macros/latex/base/ifthen.dtx
[22] D. P. Carlisle, The lscape package, Available as
CTAN/macros/latex/required/graphics/lscape.dtx
[23] John D. Hobby A Users manual for MetaPost, AT&T Bell Laboratories
Computing Science Technical Report 162, 1992. Available as
http://cm.bell-labs.com/who/hobby/cstr_162.pdf
[24] Don Hosek, The moreoats package, Available as
CTAN/macros/latex/contrib/misc/morefloats.sty
[25] Rolf Niepraschk The overpic package, Available as
CTAN/macros/latex/contrib/overpic/overpic.sty
[26] Donald Arseneau, The placeins package, Available as
CTAN/macros/latex/contrib/placeins/placeins.sty
[27] Michael C. Grant and David Carlisle, The psfrag system, version 3, Available
as CTAN/macros/latex/contrib/psfrag/pfgguide.pdf
[28] Sebastian Rahtz and Leonor Barroca, The rotating package, Available as
CTAN/macros/latex/contrib/rotating/rotating.dtx
[29] Rolf Niepraschk and Hubert Galein The sidecap package, Available as
CTAN/macros/latex/contrib/sidecap/sidecap.pdf
[30] Steven Douglas Cochran, The subg package, Available as
CTAN/macros/latex/contrib/subfig/subfig.pdf
[31] Robin Fairbairns The topcapt package, Available as
CTAN/macros/latex/contrib/misc/topcapt.sty
[32] Frank Mittelbach The varioref package, Available as
CTAN/macros/latex/required/tools/varioref.dtx
[33] David Carlisle, The xr package, Available as
CTAN/macros/latex/required/tools/xr.dtx
119
Index
\abovecaptionskip length, 66
\afterpage command, 60, 97
\Alph counter command, 67
\alph counter command, 67
\Arabic counter command, 67
\arabic counter command, 67
baseline, 10
\baselinestretch command, 68
bb, \includegraphics option, 25
bbfig, 13
\belowcaptionskip length, 66
\bottomfigrule command, 65
\bottomfraction command, 61
bottomnumber oat placement counter, 61
BoundingBox, 12
boxed gures, 99
bufsize, 14
calc package, 24
\caption command, 56, 88
caption package, 69, 90
commands, 71, 7375
\captionfont command, 90
\@captype command, 88
\centering command, 32
dierence from center environment,
32
\centerline T
E
X command, 32
\clearpage command, 59, 60
clip, \includegraphics option, 26
color package, 47
\colorbox command, 47
compressed graphics, 42, 43
converting graphics to EPS, 17
converting ps les to eps, 13
CTAN (Comprehensive T
E
X Archive Net-
work), 3
current baseline, 10
\DeclareGraphicsExtensions command,
29
\DeclareGraphicsRule command, 29, 30,
43, 44
depth, 11
\doublebox command, 102
draft, \includegraphics option, 26
endoat package, 68, 92
eps BoundingBox, 12
epsf package, 9
\epsfbox command, 9, 32
\epsfig command, 9
eso-pic package, 54
facing-page gures, 99
fancybox package, 99, 102
\fancyfoot command, 52
fancyhdr package, 52, 53
\fancyhead command, 52
fancyheadings package, 52
\fancypagestyle command, 53
\fbox command, 99
\fboxrule length, 47, 101
\fboxsep length, 47, 101, 103
\fcolorbox command, 47
\figcaption command, 89
gure references, incorrect, 56
\figurename command, 67
gures
gure environment, 55
landscape, 91
marginal, 89
non-oating, 87
placed on facing pages, 99
wide, 90
fil unit of length, 64
\fill length, 33
after package, 55, 58, 63
oat package, 89, 95
oat page, 58
\FloatBarrier command, 56
\FloatBarrier command, 59
\floatpagefraction command, 60, 61
\floatsep length, 64
\flushleft command, 90
\flushright command, 90
\@fpbot length, 64
\@fpsep length, 64
\@fptop length, 64
ghostscript, 17
ghostview, 17
gif graphics
converting to eps, 17
using in L
A
T
E
X, 42, 43
GIMP, 20
120
Graphic Converter, 19
graphics bundle, 9
graphics conversion programs, 17
graphics package, 9
graphics.cfg le, 45
GraphicsMagick, 18
\graphicspath command, 39, 40
graphicx package, 9
GSview, 17
header, graphics in, 52
height, 11
\includegraphics option, 25, 26, 33
\hfill command, 33
\hspace command, 33
ifpdf package, 24
ifthen package, 91, 97
\ifthenelse command, 91, 97
ImageMagick, 18
\includegraphics command, 9, 22
boolean options, 26
cropping options, 25
options, 25
internal commands, 64, 88
\intextsep length, 64, 88
Irfanview, 19
jpeg graphics
converting to eps, 17
converting to level 2 eps, 20
using in L
A
T
E
X, 42, 43
jpeg2ps, 20
keepaspectratio
\includegraphics option, 26
kpsewhich, T
E
X path-searching program,
45
kvec, 19
\label command, 56
landscape environment, 91, 92
landscape gures, 91
\leavevmode T
E
X command, 32
level 2 PostScript, 20
\linespread command, 68
lscape package, 91, 92
\makeatletter command, 64, 88
\makeatother command, 64, 88
marginal gures, 89
\marginpar command, 60
minipage
aligning bottoms, 36
aligning tops, 37
vertical alignment, 36
moreoats package, 60, 90
named arguments, 9
natural size, 12
NetPBM, 18
non-eps graphics
converting to eps, 17
converting to level 2 eps, 20
using in L
A
T
E
X, 42, 43
non-oating gure, 87
origin, \includegraphics option, 25
\Ovalbox command, 102
\ovalbox command, 102
overpic package, 39
\pageref command, 56
PBMPLUS, 18
pict graphics
converting to eps, 17
using in L
A
T
E
X, 43
placeins package, 56, 59
Please ask a wizard, 14
PostScript
Level 2 Wrappers, 20
\psfig command, 9, 32
psfrag, 45
\ref command, 56
\ref command, strange output, 56
reference point, 10, 11
\resizebox command, 27
\Roman counter command, 67
\roman counter command, 67
\rotatebox command, 28
rotating package, 92, 93
\rotcaption command, 92, 93
rubber length, 33, 64
scale, \includegraphics option, 25
\scalebox command, 27
SCgure environment, 95
\shadowbox command, 102, 103
\shadowsize length, 103
\shortstack command, 47
sidecap package, 95
sidewaysgure environment, 92, 93
sidewaystable environment, 95
121
\special command, 9
\subfloat command, 106
\suppressfloats command, 63
\tabcaption command, 89
TeX capacity exceeded, 41
T
E
X search path, 39
TEXINPUTS (T
E
X search path), 39
\textfloatsep length, 63, 64
\textfraction command, 61
\thefigure command, 67
\thicklines line width, 102, 103
\thinlines line width, 102, 103
tiff graphics
converting to eps, 17
converting to level 2 eps, 20
using in L
A
T
E
X, 42, 43
tiff2ps, 21
Too Many Unprocessed Floats, 58, 60
topcapt package, 67
\topfigrule command, 65
\topfraction command, 60, 61
topnumber oat placement counter, 61
totalheight, 11
\includegraphics option, 25, 33
totalnumber oat placement counter, 61
trim, \includegraphics option, 25
Unable to read an entire line, 14
Unprocessed Floats, Too Many, 58, 60
viewport, \includegraphics option, 25
wide gures, 90
width, 11
\includegraphics option, 24, 25
wizard, Please ask a wizard, 14
WMF2EPS, 19
xv, 20
122