65
\makeatletter
\addtolength{\@fpsep}{4pt}
\makeatother
increases the space between floatpage floats by 4 points.
19.2 Horizontal Lines Above/Below Figure
Horizontal lines can be automatically drawn between the text and figures which
appear at the top/bottom of the page by redefining the
\topfigurerule
\bottomfigurerule
commands. Although \topfigrule and \bottomfigrule are already defined as
L
A
T
E
Xcommands, the strange way in which they are defined requires them to be
redefined 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 figure and the line. The following commands
provide 5 points of space between the figure and the line.
\newcommand{\topfigrule}{%
\vspace*{5pt}\hrule\vspace{-5.4pt}}
\newcommand{\botfigrule}{%
\vspace*{-5.4pt}\hrule\vspace{5pt}}
The \topfigrule definition first moves 5 points down (into the \textfloatsep
spacing) to provide space between the figure 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
5points of spacing between the figure and the rule.
Since these commands place 5 points of space between the line and figure, the
spacing between the line and the text is \textfloatsep - 5pt (seeSection19.1 on
Page 64).
The line thickness can be changed from the 0.4 point default by using the \hrule
command’s height option
\newcommand{\topfigrule}{%
\vspace*{5pt}{\hrule height0.8pt}\vspace{-5.8pt}}
\newcommand{\botfigrule}{%
\vspace*{-5.8pt}{\hrule height0.8pt}\vspace{5pt}}
Notes on figure rules:
• The \topfigrule and \bottomfigrule affect neither floatpage figures nor
“here” figures (i.e., using the h option). If a “here” figure 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
Xuses many internal commands which users generally do not
need to access. To prevent these internal command names from accidentally conflicting with user-
defined names, LAT
E
Xincludes a @ in these internal command names. Since LAT
E
Xcommand names
can contain only letters, defining 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 LAT
E
Xto treat @ as a letter, thus allowing users to use @ in command names. The
\makeatother command causes LAT
E
Xto revert to the normal behavior of treating @ as a non-letter.
65
58
Table 11: Figure Rule Commands
\topfigrule
This command is executed after the last float at the top of a
page, but before the \textfloatsep spacing (seeSection19.1
on Page 64).
\bottomfigrule
This command is executed before the first float at the bottom
of a page, but after the \textfloatsep spacing.
• The horizontal rules are as wide as the text, even if wider figures (seeSection23
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
LAT
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}
produceFigure13, 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
Xcommands \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}
produceFigure14, 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 floats, the commands
\setlength{\abovecaptionskip}{0pt}
\setlength{\belowcaptionskip}{10pt}
can be issued in the document’s preamble to affect the caption spacing for all the
document’s captions (figures and tables). If a document contains captions at the top
of some floats and at the bottom of other floats, it may be desirable to define the
following command
66
41
\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 float.
Two other methods for producing properly-spaced top captions are
• The caption package’s position=top option inTable16on Page 74 swaps the
meaning of \abovecaptionskip and \belowcaptionskip
• The topcapt package [31], defines a \topcaption command which produces a
caption with the \abovecaptionskip and \belowcaptionskip lengths inter-
changed.
19.4 Caption Label
By default, LAT
E
Xinserts a caption label such as “Figure 13: ” at the beginning of the
the caption. The “Figure” portion can be changed by redefining the \figurename
command. For example, the commands
\begin{figure}
\centering
\includegraphics[width=1in]{graphic}
\renewcommand{\figurename}{Fig.}
\caption{This is the Caption}
\end{figure}
produceFigure15. The caption font, the “:” delimiter, and other caption charac-
teristics can be customized with the caption package (seeSection20 on Page 69).
Graphic
Fig. 15: This is the Caption
19.5 Caption Numbering
The default method for numbering the figures is Arabic (1,2,3, 4,. ..). This can be
changed by redefining the \thefigure command.
The number of the current figure is stored in the figure counter. The \thefigure
command specifies 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 figures to be numbered with uppercase Roman numerals (I,II, III, IV,.. .).
Notes on figure numbering:
• There must be 26 or fewer figures to use the \alph or \Alph commands.
• Since Roman numbering produces longer figure numbers (e.g., XVIII vs. 18),
using \Roman or \roman may cause spacing problems in the Table of Figures.
67
59
19.6 Moving Figures to End of Document
Some journals require that tables and figures be separated from the text. The endfloat
package moves all the figures 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
floats would have appeared in the text. Such notes can be turned off with the
nomarkers package option
\usepackage[nomarkers]{endfloat}
The text of these notes can be changed by redefining 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 figures is included before the figures 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 figures
and tables, respectively.
• The figures appear before the tables. The tablesfirst package option reverses
this order.
• A \clearpage command is executed after each figure and table, causing each
float 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 float.
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}
A1.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 effect.
29
Although the doublespace package also sets line spacing, it has not been properly updated to
LAT
E
X2
ε
,causing it to interact with many packages. As a result, setspace should be used instead.
68
53
20 Customizing Captions with caption package
Section 19.4 4 on Page 67 describes s how to customize the e caption n label while Sec-
tion 19.3onPage66describeshowtocustomizethecaptionverticalspacing. 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 floats as it officially supports
the float, longtable, and subfigure packages and it also works with the floatfig, rotating,
supertabular, and wrapfig 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 inSection20.2 and listed inTable12.
• 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 inTa-
ble 14and Table 15onPage73withexamplesprovidedin Section 20.4.1
on Page 76.
Caption Spacing Options customize the caption vertical spacing. These
options are listed inTable16on Page 74 with examples provided inSec-
tion 20.4.2onPage77.
Caption Label Options customize the caption label and separator. These
options are listed inTable17on Page 74 with examples provided inSec-
tion 20.4.3onPage79.
Caption Formatting Options customize the caption formatting. These op-
tions are listed inTable 18 on Page 75 with examples provided inSec-
tion 20.4.4onPage81.
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 inSection20.4 on Page 76.
• Users can define a collection of caption options, called caption styles. The entire
collection of options can be specified with the style= option. SeeSection20.5.1
on Page 83.
• Instead of just using the built-in option values, users can define their own option
values as described inSection20.5.2.
30
Version3 of the caption package replacesprevious caption versions as well as the caption2 package.
31
Although caption package provides commands to customize a caption’s font, not every combi-
nation of font attributes necessarily exists in the font being used. For example, suppose the user
specifies a font with roman family, small caps shape, and bold series. If that combination is not
supported by the current font, then LAT
E
Xmay instead substitute a font with roman family, upright
shape, and bold series.
69
44
20.2 Caption Commands
Section 17.1onPage56describesthe\captioncommandandsomecustomizationis
described in andSection19. The caption package provides many more customization
options.
The caption package slightly changes this \caption command and also introduces
new variants as described inTable12. The highlights include:
• The caption package changes the \caption command such that if the optional
argument is specified but empty
\caption[]{caption text}
then no entry is made in the list of figures/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: figure 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 figure environment. This is useful for
1. Placing a table and figure side-by-side as described in Section 30 on
Page 109).
2. Constructing marginal figures (seeSection22 on Page 89).
3. Constructing non-floating figures (seeSection21 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 float contents.
20.3 Customizing Captions with Caption Command
As mentioned earlier inSection20.1 on Page 69, the caption package allows the user
to customize the caption font, spacing, label, and format. The options (listed in
Tables13 -18) can be specified in either of two ways:
usepackage options
\usepackage[options]{caption} where [options] are any combination of
options specified inTable13. 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 specified options to be in ef-
fect for the remaining environment. (A \captionsetup command in a docu-
ment’s preamble effects the entire document.) For example
\captionsetup{margin=10pt,font=small,labelfont=bf}
70
Documents you may be interested
Documents you may be interested