Typesetting captions with the caption package^{∗}

Axel Sommerfeldt

                 caption@sommerfeldt.net

2004/07/16

Abstract

The caption package provides many ways to customise the captions in floating environments such figure and table and cooperates with many other packages.^{1}

1 Introduction

Within the standard L^{A}TEX classes captions haven’t received the attention they deserve. Simply typeset as an ordinary paragraph there is no remarkable visual difference from the rest of the text, like here:

Figure 1: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

There should be possibilities to change this; e.g., it would be nice if you can make the text of the caption a little bit smaller as the normal text, add an extra margin, typeset the caption label with the same font family and shape as your headings etc. Just like this one:

Figure 2: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

With this package you can do this easily as there are many ready-to-use caption formatting options, but you are free to define your very own stuff, too.

∗This package has version number v3.0c, last revised 2004/07/16.

1A complete re-work of the user interface done together with Steven D. Cochran and Frank Mittelbach has lead to this new enhanced version 3.0.

2 Using the package

\usepackage Insert
     \usepackage[⟨options⟩]{caption}[2004/07/16]

into the preamble of your document, i.e. the part of your document between \documentclass and \begin{document}. The options control how your captions will look like; e.g.,

     \usepackage[margin=10pt,font=small,labelfont=bf]{caption}

would result in captions looking like the second one in the introduction.

\captionsetup For a later change of options the caption package provides the command

\captionsetup[⟨float type⟩]{⟨options⟩}

So

     \usepackage[margin=10pt,font=small,labelfont=bf]{caption}

and

     \usepackage{caption}
     \captionsetup{margin=10pt,font=small,labelfont=bf}

are equal in their results. It’s good to know that \captionsetup has an effect on the current environment only. So if you want to change some settings for the current figure or table only, just place the \captionsetup command inside the figure or table right before the \caption command. For example

     \begin{figure}

…

       \captionsetup{singlelinecheck=off}
       \caption{. . . }
     \end{figure}

switches the single-line-check off, but only for this figure so all the other captions remain untouched. (For a description of the optional parameter ⟨float type⟩ see section 4: “Useful stuff”.)

3 Options

3.1 Formatting

format= A figure or table caption mainly consits of three parts: the caption label, which says if this object is a ‘Figure’ or ‘Table’ and what number is associated with it, the caption text itself, which is normally a short description of contents, and the caption separator which separates the text from the label. The caption format determines how this information will be presented; it is specified with the option

format=⟨format name⟩ ,

having the name of the caption format as its argument. There are two standard caption formats:^{2}

default Typesets the captions as a normal paragraph. (This is the default behaviour, it is adapted from the standard L^{A}TEX document classes.)

hang Indents the caption text, so it will ‘hang’ under the first line of the text.

An example: Specifing the option

     format=hang

yields captions like this:

Figure 3: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

indention= For both formats (default and hang) you can setup an extra indention starting at the second line of the caption. You do this with the option

     indention=⟨amount⟩.

Two examples:

     format=default,indention=.5cm

Figure 4: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

     format=hang,indention=-0.5cm

Figure 5: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

labelformat= With the option

labelformat=⟨label format name⟩

you specify how the caption label will be typeset. There are three standard caption label formats:

empty The caption label will be empty. This option only makes sense when used together with other options like labelsep=none. simple The caption label will be typeset as a name and a number. (This

2You have the option to define your own ones, too. See section 5: “Do it yourself!” for details.

is the default behaviour.)

parens The number of the caption label will be typeset in parentheses.

An example: Using the options

     labelformat=parens,labelsep=quad

yields captions like this one:

Figure (6) White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

labelsep= With the options

labelsep=⟨label separator name⟩

you specify what caption separator will be used. You can choose one of the following:

none There is no caption separator. This option only makes sense when used together with other options like labelformat=empty.

colon The caption label and text will be separated by a colon and a space. (This is the default one.)

period The caption label and text will be separated by a period and a space.

space The caption label and text will be separated by a single space.

quad The caption label and text will be separated by a \quad.

newline The caption label and text will be separated by a line break

             (\newline).

Two examples:

     labelsep=period

Figure 7. White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

     labelsep=newline,singlelinecheck=false

Figure 8 White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

3.2 Justification

justification= As addition to the caption format you could also specify a caption justification; it is specified with the option

justification=⟨justification name⟩ .

You can choose one of the following:

justified Typesets the caption as a normal paragraph. (This is the default.)

centering Each line of the caption will be centered.

centerlast The last line of each paragraph of the caption text will be centered.

centerfirst Only the first line of the caption will be centered.

raggedright Each line of the caption will be moved to the left margin.

RaggedRight Each line of the caption will be moved to the left margin, too. But this time the command \RaggedRight of the ragged2e package will be used to achieve this. This difference is that this time the word breaking algorithm of TEX will work inside the caption.

raggedleft Each line of the caption will be moved to the right margin.

Two examples:

     justification=centerlast

Figure 9: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the

many championship courses.

     format=hang,justification=raggedright

Figure 10: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

singlelinecheck= If the caption fit in a single line it will always be centered, ignoring the justification you set:

Figure 11: A short caption.

This behaviour is adapted from the standard L^{A}TEX document classes article, report, and book), but using the caption package you can switch this special treatment of such short captions off with the option

     singlelinecheck={⟨bool⟩} .

Using false, no, off or 0 for ⟨bool⟩ you switch off the extra centering:

     singlelinecheck=false

Doing so the above short caption would look like Figure 12: A short caption. Using true, yes, on or 1 for ⟨bool⟩ you switch on the extra centering again. (The default is on.)

3.3 Fonts

font= There are three font options which affects different parts of the caption: One af-

labelfont=
textfont=

fecting the whole caption (font), one which only affects the caption label and separator (labelfont) and at last one which only affects the caption text (testfont). You set them up using the options

font={⟨font options⟩} ,
labelfont={⟨font options⟩} and
textfont={⟨font options⟩} .

And these are the available font options:

scriptsize Very small size

footnotesize The size usually used for footnotes

small Small size

normalsize Normal size

large Large size

Large Even larger size

up Upright shape it Italic shape sl Slanted shape sc Small Caps shape md Medium series bf Bold series rm Roman family sf Sans Serif family

tt           Typewriter family

If you use only one of these options you can omit the braces; e.g., the options

font={small} and font=small yield the same result.

Two examples:

   font={small,it},labelfont=bf

Figure 13: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

   font=small,labelfont=bf,textfont=it

Figure 14: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

3.4 Margins and further paragraph options

margin= For all captions you can specify either an extra margin or a fixed width. You do width= this using the options

margin=⟨amount⟩ or
width=⟨amount⟩

Nevertheless what option you use, the left and right margin will be the same. Two examples illustrating this:

   margin=10pt

Figure 15: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

   width=.75\textwidth

Figure 16: White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

parskip= This option is useful for captions containing more than one paragraph. If specifies the extra vertical space inserted between them:

   parskip=⟨amount⟩

One example:

   margin=10pt,parskip=5pt

Figure 17: First paragraph of the caption. This one contains some test, just to show how these options affect the layout of the caption.

Second paragraph of the caption. This one contains some text, too, to show how these options affect the layout of the caption.

hangindent= The option
     hangindent=⟨amount⟩

is for setting up a hanging indention starting from the second line of each paragraph. If the caption contains just a single paragraph, using this option leads to the same result as the option indention= you already know about. But if the caption contains multiple paragraphs you will notice the difference:

     format=hang,indention=-.5cm

Figure 18: First paragraph of the caption. This one contains some test, just to show how these options affect the layout of the caption. Second paragraph of the caption. This one contains some text, too, to show how these options affect the layout of the caption.

     format=hang,hangindent=-.5cm

Figure 19: First paragraph of the caption. This one contains some test, just to

show how these options affect the layout of the caption.

Second paragraph of the caption. This one contains some text, too, to show how these options affect the layout of the caption.

3.5 Styles

style= A suitable combination of caption options is called caption style. You can compare them more or less to page styles which you set up with \pagestyle: The caption style provides all settings for a whole caption layout. You switch to an already defined caption style with the option

style=⟨style name⟩ .

The caption package usually defines only the style default which puts all options you already know about to the default ones. This means that specifing the option

     style=default

has the same effect as specifing all these options:

     format=default,labelformat=simple,labelsep=colon,
     justification=justified,font=default,labelfont=default,
     textfont=default,margin=0pt,indention=0pt,parindent=0pt
     hangindent=0pt,singlelinecheck=true

3.6 Skips

aboveskip= The spaces above and below the caption are controlled by the skips \abovecaptionskip

belowskip= and \belowcaptionskip. The standard L^{A}TEX document classes article, report
and book set \abovecaptionskip to 10pt and \belowcaptionskip to 0pt.

Both skips can be changed with the command \setlength, but you can use these options, too:

aboveskip=⟨amount⟩ and

     belowskip=⟨amount⟩ .

position= Using \abovecaptionskip and \belowcaptionskip has a major design flaw: If

the caption is typeset above (and not below) the figure or table they are not set up very useful at default, because there will be some extra space above the caption but no space between the caption and the figure or table itself. (Remember:

\belowcaptionskip is usually set to 0pt.)

Please compare the spacing in these small tables:

Table 1: A table

A B C D

A B C D

Table 2: A table

But you can fix this by using the option position=: It specifies how the spacing above and below the caption will be used:

     position=top (or position=above)

tells the caption package to use the spacing useful for caption above the figure or table and

     position=bottom (or position=below)

tells the caption package to use the spacing useful for captions below the figure or table. (The last one is the default setting.) So adding an extra \captionsetup{position=top} to the left example table gives you proper spacing around both captions:

Table 3: A table

A B C D

A B C D

Table 4: A table

(Technically speaking \abovecaptionskip and \belowcaptionskip will be swapped if you specify the option position=top, so in both cases \abovecaptionskip will be used between the caption and the figure or table itself.)

tableposition= This option is especially useful when used together with the optional argument of the \captionsetup command. (See section 4: “Useful stuff” for details.) E.g.,

     \captionsetup[table]{position=top}

causes all captions within tables to be treated as captions above the table (regarding spacing around it). Because this is a very common setting the caption package

New feature v3.0a

offers an abbreviating option for the use with \usepackage:

     \usepackage[. . . ,tableposition=top]{caption}

is equivalent to

     \usepackage[. . . ]{caption}
     \captionsetup[table]{position=top}

4 Useful stuff

\caption The command

\caption[⟨lst entry⟩]{⟨heading⟩}

typesets the caption inside a floating environment like figure or table. Well, you already know this, but what is new is the fact then when you leave the argument ⟨lst entry⟩ empty, no entry in the list of figures or tables will be made; e.g.,

     \caption[]{A figure without entry in the list of figures.}

\caption* The longtable package defines the command \caption* which typesets the caption without label and without entry in the list of tables. An example:

     \begin{longtable}{cc}
       \caption*{A table}\\
       A & B \\
       C & D \\
     \end{longtable}

looks like

A table

A B
C D

This package does it, too, so you can use this command now within every floating environment like figure or table. Additionally you can specify an entry for the list of figures or tables within square brackets, like here:

     \begin{table}
       \caption*[List entry for the table]{A table}
       \begin{tabular}{cc}
         A & B \\
         C & D \\
       \end{longtable}
     \end{table}

\captionof Sometimes you want to typeset a caption outside a floating environment, putting \captionof* a figure within a minipage for instance. For this purpose the caption package

offers the command

\captionof{⟨float type⟩}[⟨lst entry⟩]{⟨heading⟩} .

Note that the first argument, the ⟨float type⟩, is mandatory here, because the \captionof command needs to know which name to put into the caption label (e.g. “Figure” or “Table”) and in which list to put the contents entry. An example:

     \captionof{figure}{A figure}
     \captionof{table}{A table}

typesets captions like this:

Figure 20: A figure

Table 6: A table

The star variant \captionof* has the same behaviour as the \caption* command: it typesets the caption without label and without entry to the list of figures or tables (if not specified otherwise). Please use both \captionof and \captionof* only inside environments (like minipage or \parbox), otherwise a page break can appear between content and caption. Furthermore some strange effects could occur (e.g., wrong spacing around captions).

\ContinuedFloat Sometimes you want to split figures or tables without giving them their own reference number. This is what the command

     \ContinuedFloat

is for; it should be used as first command inside the floating environment. It prevents the increment of the relevant counter so a figure or table with a \ContinuedFloat in it gets the same reference number as the figure or table before. An example:

     \begin{table}
     \caption{A table}

…

     \end{table}

…

     \begin{table}\ContinuedFloat
     \caption{A table (cont.)}

…

     \end{table}

gives the following result:

Table 7: A table … Table 7: A table (cont.)

\captionsetup We already know the \captionsetup command (see section 2: “Using the package”), but this time we get enlighten about the optional argument ⟨float type⟩. Remember, the syntax of this command is

\captionsetup[⟨float type⟩]{⟨options⟩} .

If a ⟨float type⟩ gets specified, all the ⟨options⟩ don’t change anything at this time. Instead they only get marked for a later use, when a caption inside of a floating environment of the particular type ⟨float type⟩ gets typeset. For example

     \captionsetup[figure]{⟨options⟩}

forces captions within a figure environment to use the given ⟨options⟩. Here comes an example to illustrate this:

     \captionsetup{font=small}
     \captionsetup[figure]{labelfont=bf}

gives captions like this:

Figure 21: A figure

Table 8: A table

As you see the command \captionsetup[figure]{labelfont=bf} only changed

the font of the figure caption labels, not touching all other ones.

\clearcaptionsetup If you want to get rid of these parameters marked for an automatic use within a particular environment you can use the command

     \clearcaptionsetup{⟨Typ⟩} .

For example \clearcaptionsetup{figure} would clear the extra handling in the example above:

Figure 22: A figure

Table 9: A table

As ⟨float type⟩ you can usually give one of these only two: figure and table. But as we will see later some L^{A}TEX packages exist (like the float package for example) who can define additional floating enviroments and these two commands also works with them.

5 Do it yourself!

A family of commands is provided to allow users to define their own formats. This enables information on separators, justification, fonts, and styles to be associated with a name and kept in one place (these commands need to appear in the document preamble, this is the part between \documentclass and

\begin{document}).

\DeclareCaptionFormat You can define your own caption formats using the command

\DeclareCaptionFormat{⟨name⟩}{⟨code using #1, #2 and #3 ⟩} .

At usage the system replaces #1 with the caption label, #2 with the separator and #3 with the text. So the standard format default is defined inside caption.sty as

     \DeclareCaptionFormat{default}{#1#2#3\par}

\DeclareCaptionLabelFormat Likewise you can define your own caption label formats:

     \DeclareCaptionLabelFormat{⟨name⟩}{⟨code using #1 and #2 ⟩}

At usage #1 gets replaced with the name (e.g. “figure”) and #2 gets replaced with the reference number (e.g. “12”).

\bothIfFirst When you define your own caption label formats and use the subfig package[7], too, \bothIfSecond you must take care of empty caption label names. For this purpose the commands

\bothIfFirst{⟨first arg⟩}{⟨second arg⟩} and \bothIfSecond{⟨first arg⟩}{⟨second arg⟩}

are offered. \bothIfFirst tests if the first argument is empty, \bothIfSecond tests if the second argument is empty. If it is so both arguments get typeset, otherwise none of them. For example the standard label format simple isn’t defined as

     \DeclareCaptionLabelFormat{simple}{#1 #2} ,

because this could cause an extra space if #1 is empty. Instead simple is defined as

     \DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{ }#2} ,

causing the space to appear only if the label name is present. You can define your own caption label separators with

\DeclareCaptionLabelSeparator
     \DeclareCaptionLabelSeparator{⟨name⟩}{⟨code⟩} .

Again an easy example taken from caption.sty itself:

     \DeclareCaptionLabelSeparator{colon}{: }

\DeclareCaptionJustification You can define your own caption justifications with

     \DeclareCaptionJustification{⟨name⟩}{⟨code⟩} .

The ⟨code⟩ simply gets typeset just before the caption. E.g. using the justification raggedright, which is defined as

     \DeclareCaptionJustification{raggedright}{\raggedright} ,

yields captions with all lines moved to the left margin.

\DeclareCaptionFont You can define your own caption fonts with

     \DeclareCaptionFont{⟨name⟩}{⟨code⟩} .

For example this package defines the options small and bf as

     \DeclareCaptionFont{small}{\small} and
     \DeclareCaptionFont{bf}{\bfseries} .

\DeclareCaptionStyle The best one comes at last: You can define your own caption styles with

\DeclareCaptionStyle{⟨name⟩}[⟨additional options⟩]{⟨options⟩}

Remember, caption styles are just a collection of suitable options, saved under a given name. You can wake up these options at any time with the option style=⟨style name⟩. All caption styles are based on the default set of options. (See section 3.5: “Styles” for a complete list.) So you only need to specify options which are different to them. If you specify ⟨additional options⟩ they get used in addition when the caption fits into a single line and this check was not disabled with the option

singlelinecheck=off.

Again a very easy example taken from caption.sty:

     \DeclareCaptionStyle{default}[justification=centering]{}

5.1 Examples

If you would like to have a colon and a line break as caption separator you could define it this way:

     \DeclareCaptionLabelSeparator{period-newline}{. \newline}
Selecting this separator with \captionsetup{labelsep=period-newline} you

get captions like this:

Figure 23.

White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

For short captions—which fit into one single line—this separator may not be satisfying, even when the automatically centering process is switched off (with

singlelinecheck=off):

Figure 24. A figure.

An own caption style which selects another caption separator automatically puts this right:

     \DeclareCaptionStyle{period-newline}%
       [labelsep=period]{labelsep=period-newline}

Figure 25. A figure. If you would like to keep the centering of these captions an appropriate definition is

     \DeclareCaptionStyle{period-newline}%
       [labelsep=period,justification=centering]%
       {labelsep=period-newline}

Using this definition short captions look like

Figure 26. A figure.

while long ones still have a line break after the caption label. Another example: You want captions to look like this:

White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

(Figure 27)

You could do it this way:

  \DeclareCaptionFormat{reverse}{#3#2#1}
  \DeclareCaptionLabelFormat{fullparens}{(\bothIfFirst{#1}{ }#2)}
  \DeclareCaptionLabelSeparator{fill}{\hfill}
  \captionsetup{format=reverse,labelformat=fullparens,
                labelsep=fill,font=small,labelfont=it}

Another example: The caption text should go into the left margin; a possible solution would be:

  \DeclareCaptionFormat{llap}{\llap{#1#2}#3\par}
  \captionsetup{format=llap,singlelinecheck=no,
                labelsep=quad}

As a result you would get captions like this:

Figure 28 White sand beaches. The pink smoothness of the conch shell. A sea abundant with possibilities. Duty-free shops filled with Europe’s finest gifts and perfumes. Play your favorite game of golf amidst the tropical greens on one of the many championship courses.

6 Using non-standard document classes

New description The caption package was developed using the standard document classes article,

v3.0c

report and book. But it should work with other document classes, too. (If there are any difficulties about a special document class please don’t hesitate to write me an e-mail. Thank you.) If you would like to use the caption package with the KOMA-Script classes or with the memoir class, you have to take into consideration that all the possibilities for customization of the captions the KOMA-Script classes or memoir class have to offer will get lost. (And they have a lot of possibilites to offer!) So com-

mands like \captionabove, \captionbelow, \captionformat, \figureformat,
\tableformat, \setcapindent, \setcaphanging, \captionstyle etc. will not

work anymore. So make a wise decision!

7 Using other packages

The caption package contains special adaptions to other packages who handle with captions, too, so the captions always should look like you have specified them to look like.

These are the packages the caption package is adapted to:

float  Gives you the possibility to define new floating environments
listings  Typesets source code listings
longtable  Typesets tables spanned over multiple pages
rotating  Supports rotated figures and tables
sidecap  Offers captions beside figures or tables
supertabular Typesets tables spanned over multiple pages

If you use one of the above packages together with the caption package you get

New feature v3.0b

the additional possibility to set up captions with

\captionsetup[⟨environment⟩]{⟨options⟩} .

These options will apply for captions inside these environments automatically. For example

     \captionsetup[lstlisting]{labelfont=bf}

forces captions inside the lstlisting environment to have bold labels. (Please note that this do not work with the sideways environments offered by the rotating package.) If a certain support is not desired you can switch it off using the caption package option

     \usepackage[. . . ,⟨package⟩=no]{caption} .

For example specifing the option float=no means you don’t like the caption package to support the float package. (Note: You can specify these options only within the \usepackage command, especially not at a later time with \captionsetup.) For further information about the supported packages please take a look at the documentation belonging to it or buy yourself The L^{A}TEX Companion[1].

7.1 The float package

A very useful feature is provided by the float package[2]: It offers the float placement specifier H which is much more restrictive than the specifier h offered by L^{A}TEX. While the latter one is only a recommendation to L^{A}TEX to set the float “here”, the H forces the float to appear exactly at the spot where it occurs in your input file and nowhere else. Furthermore it offers different styles for floating environments, these styles are plain, plaintop, ruled, and boxed. You can link one of these styles to either new floating environments or to one of the existing environments figure and

table.

If you are using the caption package together with the float package this caption style called ruled gets defined automatically:

     \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space}

This style represents the caption layout in ruled styled floats. For you as an end user this means that captions within ruled floats will always look like this, nevertheless what generic caption options do you specify:

Program 7.1 The first program. This hasn’t got anything to do with the package but is included as an example. Note the ruled float style.

 #include <stdio.h>
 int main(int argc, char **argv)
 {
        for (int i = 0; i < argc; ++i)
                printf("argv[%d] = %s\n", i, argv[i]);
        return 0;
 }

If you want a different layout for ruled captions you have to define your own one using the command

     \DeclareCaptionStyle{ruled}{⟨options⟩} .

This mechanism also works with all other float styles. If you want a special caption layout for plain or boxed floats for example you can simply define a suitable caption style with the same name as the float style.

7.2 The listings package

New description The listings package[3] is a source code printer for L^{A}TEX. You can typeset stand

v3.0b

alone files as well as listings with an environment similar to verbatim as well as you can print code snippets using a command similar to \verb. Many parameters control the output and if your preferred programming language isn’t already supported, you can make your own definition. Note: For successful cooperation you need the listings package version 1.2 or higher. You’ll get an error message when using an older version!

7.3 The longtable package

The longtable package[4] offers the environment longtable which behaves similar to the tabular environment, but the table itself can span multiple pages.

7.4 The rotating package

The rotating package[5] offers the floating environments sidewaysfigure and sidewaystable which are just like normal figures and tables but rotated by 90 degree. Furthermore they always use a full page on their own.

7.5 The sidecap package

New description The sidecap package[6] offers the floating environments SCfigure and SCtable

v3.0b

which are like normal figures and tables but the caption will be put beside the contents.

The sidecap package offers it’s own options for justification. If set, they will override the one specified with the caption option justification= for captions beside their contents.

listof= Using the sidecap package you will probably notice that suppressing the entry in the list of figures or tables with \caption[]{… } won’t work inside these environments. This is caused by the implementation design of the sidecap package, but you can use \captionsetup{listof=false} inside the figure or table as an alternative here.

[figure] Figure 29: A small example with the caption beside the figure.

7.6 The supertabular package

The supertabular package[8] offers the environment supertabular which is quite similar to the longtable environment provided by the longtable package. Both offers the typesetting of tables which can span multiple pages. For a detailed discussion about the differences between these powerful packages please take a look at The L^{A}TEX Companion[1].

7.7 Known incompatibilities

New description Using the caption package together with one of the following packages is not rec-

v3.0b

ommended; usually this would cause unwanted side effects or even errors:

ccaption, hvfloat, nonfloat

Furthermore using the hypcap package will cause major limitations: All extensions to the \caption command gets lost, the option labelformat= is not working at all and local settings done with \captionsetup[…]{… } lead not to the desired results. This is caused by the implementation design of the hypcap package, see section 1.3 “Limitations” of the hypcap documentation for details.

8 Compatibility to older versions

8.1 caption version 1.x

This version of the caption package still supports the old options and commands provided by the version 1.x of this package. So there shouldn’t occur any problems compiling old documents, but please don’t mix old options and commands with the new ones. This isn’t supported and can yield to ugly side effects. Here comes a short oversight of the old options and commands and how they are replaced within this version of the caption package:

caption 1.x  caption 3.x

normal                             format=default
hang                               format=hang
isu                                format=hang
center                             justification=centering
centerlast                         justification=centerlast
anne                               justification=centerlast
nooneline                          singlelinecheck=off
scriptsize                         font=scriptsize
footnotesize                       font=footnotesize
small                              font=small
normalsize                         font=normalsize
large                              font=large
Large                              font=Large
up                                 labelfont=up
it                                 labelfont=it
sl                                 labelfont=sl
sc                                 labelfont=sc
md                                 labelfont=md
bf                                 labelfont=bf
rm                                 labelfont=rm
sf                                 labelfont=sf
tt                                 labelfont=tt
\setlength{\captionmargin}         margin=⟨amount⟩
\renewcommand{\captionfont}        \DeclareCaptionFont

                                   + \captionsetup{font=⟨name⟩}

\renewcommand{\captionsize}        \DeclareCaptionFont

                                   + \captionsetup{font=⟨name⟩}

\renewcommand{\captionlabelfont}   \DeclareCaptionLabelFont

                                   + \captionsetup{labelfont=⟨name⟩}

8.2 caption2 version 2.x

Although they do very similar stuff the packages caption and caption2 have a very different implementation design. So this version of the caption package isn’t compatible to the caption2 package at all. Of course for compiling old documents you can still use the caption2 package, the latest version is provided with this package. But newly created documents shouldn’t use the caption2 package, please use the caption package instead as described in this manual.

9 Further reading

I recommend the following documents for further reading:

• The TEX FAQ - Frequently asked questions about TEX and L^{A}TEX:

      http://faq.tug.org/

• A French FAQ can be found at

      http://www.grappa.univ-lille3.fr/FAQ-LaTeX/

• epslatex from Keith Reckdahl contains many tips around graphics in

L^{A}TEX 2ε. You will find this document in the directory

    ftp://ftp.ctan.org/pub/tex/info/
as epslatex.ps and epslatex.pdf.

There is also a french translation available:

    ftp://ftp.ctan.org/pub/tex/info/fepslatex.ps

10 Thanks

I would like to thank Katja Melzner, Steven D. Cochran, Frank Mittelbach, David Carlisle, and Ivor Tiefenbrun.

11 The Implementation

I’m sorry for the missing code documentation, I will do this ASAP.

 1 %
 2 % Identification
 3 %
 4 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
 5 \ProvidesPackage{caption}[2004/07/16 v3.0c Customising captions (AS)]

11.1 Kernel

 6 %\NeedsTeXFormat{LaTeX2e}[1994/12/01]
 7 %\ProvidesPackage{caption3}[2004/xx/xx v3.1 caption3 kernel (AS)]
 8 %
 9 % Helpers

10 %

11 \providecommand*\@nameundef[1]{%
12 \expandafter\let\csname #1\endcsname\@undefined}

13 %

14 \providecommand\l@addto@macro[2]{%
15 \begingroup
16  \toks@\expandafter{#1#2}%
17  \edef\@tempa{\endgroup\def\noexpand#1{\the\toks@}}%
18 \@tempa}

19 %

20 \def\bothIfFirst#1#2{%
21 \protected@edef\caption@tempa{#1}%
22 \ifx\caption@tempa\@empty\else
23  #1#2%
24 \fi}
25 \def\bothIfSecond#1#2{%
26 \protected@edef\caption@tempa{#2}%
27 \ifx\caption@tempa\@empty\else
28  #1#2%
29 \fi}

30 %

31 \def\caption@ifinlist#1#2{%
32 \let\next\@secondoftwo
33 \edef\caption@tempa{#1}%
34 \@for\caption@tempb:={#2}\do{%
35  \ifx\caption@tempa\caption@tempb
36  \let\next\@firstoftwo
37  \fi}%
38 \next}

39 %

40 % Setting boolean options:
41 % \caption@setbool{<name>}{<value> = false/true/no/yes/off/on/0/1}
42 % \caption@ifbool{<name>}{<if-clause>}{<else-clause>}

43 %

44 \def\caption@setbool#1#2{%
45 \caption@ifinlist{#2}{1,true,yes,on}{%
46  \expandafter\let\csname caption@if#1\endcsname\@firstoftwo
47 }{\caption@ifinlist{#2}{0,false,no,off}{%
48  \expandafter\let\csname caption@if#1\endcsname\@secondoftwo

49 }{%
50  \PackageError{caption}{Undefined boolean value `#2'}{\caption@eh}%
51 }}}

52 %

53 \def\caption@ifbool#1{\@nameuse{caption@if#1}}

54 %

55 % Obsolete stuff for compatiblity to caption.sty v1.3

56 %

57 % \changes{v3.0a}{16 Jul 04}{Minimum adaption to the memoir class}
58 \providecommand\captionsize{}%  changed v3.0a+c

59 %

60 % Margin resp. width

61 %

62 \newdimen\captionmargin
63 \newdimen\captionwidth
64 \newif\ifcaption@width
65 \newcommand\caption@setmargin{%
66 \caption@widthfalse
67 \setlength\captionmargin}
68 \newcommand\caption@setwidth{%
69 \caption@widthtrue
70 \setlength\captionwidth}

71 %

72 % Indentions

73 %

74 \newdimen\captionindent
75 \newdimen\captionparindent
76 \newdimen\captionhangindent

77 %

78 % Support of \caption*

79 %

80 \newif\ifcaption@star

81 %

82 % Vertical spaces before/after captions

83 %

84 \@ifundefined{abovecaptionskip}{%
85 \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}
86 \@ifundefined{belowcaptionskip}{%
87 \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}

88 %

89 % Error

90 %

91 \newcommand\caption@eh{%
92 If you do not understand this error, please take a closer look\MessageBreak
93 at the documentation of the `caption' package.\MessageBreak
94 \@ehc}

95 %

96 % Loading the keyval package
97 % (We need it for option handling)

98 %

99 \RequirePackage{keyval}[1997/11/10]
100 \providecommand*\undefine@key[2]{%
101 \@nameundef{KV@#1@#2}\@nameundef{KV@#1@#2@default}}

102 %

103 % Reset to default parameters
104 % (Note that this does not touch the skips and the positioning.)

105 %

106 \newcommand\caption@setdefault{\captionsetup{%
107 format=default,labelformat=default,labelsep=default,justification=default,%
108 font=default,labelfont=default,textfont=default,%
109 margin=0pt,indention=0pt,parindent=0pt,hangindent=0pt,singlelinecheck}}

110 %

111 % \DeclareCaptionStyle{<name>}[<additional(!) single-line-list-of-KV>]{<list-of-KV>}
112 % \caption@setstyle{<name>}

113 %

114 % (Bugfix v3.0a: We pass through argument #3 so extra spaces between the
115 %  arguments do make any harm.)

116 %

117 \newcommand*\DeclareCaptionStyle[1]{%
118 \@ifnextchar[{\caption@declarestyle{#1}}{\caption@declarestyle{#1}[]}}
119 \def\caption@declarestyle#1[#2]#3{%  bugfixed v3.0a
120 \global\@namedef{caption@sls@#1}{#2}%
121 \global\@namedef{caption@sty@#1}{#3}}
122 \@onlypreamble\DeclareCaptionStyle
123 \@onlypreamble\caption@declarestyle

124 %

125 \newcommand*\caption@setstyle[1]{%
126 \@ifundefined{caption@sty@#1}%
127  {\PackageError{caption}{Undefined caption style `#1'}{\caption@eh}}%
128  {\expandafter\let\expandafter\caption@sls\csname caption@sls@#1\endcsname
129  \caption@setdefault\caption@esetup{\csname caption@sty@#1\endcsname}}}

130 %

131 % Pre-defined styles

132 %

133 \DeclareCaptionStyle{default}[justification=centering]{}

134 %

135 % \DeclareCaptionFormat{<name>}{<code with #1, #2, and #3>}
136 % \caption@setformat{<name>}

137 %

138 \newcommand\DeclareCaptionFormat[2]{%  bugfixed v3.0a
139 \global\long\expandafter\def\csname caption@fmt@#1\endcsname##1##2##3{#2}}
140 \@onlypreamble\DeclareCaptionFormat

141 %

142 \newcommand*\caption@setformat[1]{%
143 \@ifundefined{caption@fmt@#1}%
144  {\PackageError{caption}{Undefined caption format `#1'}{\caption@eh}}%
145  {\expandafter\let\expandafter\caption@fmt\csname caption@fmt@#1\endcsname}}

146 %

147 % Pre-defined formats

148 %

149 \DeclareCaptionFormat{normal}{#1#2#3\par}
150 \DeclareCaptionFormat{hang}{%
151 \@hangfrom{#1#2}%
152 \advance\captionparindent\hangindent
153 \advance\captionhangindent\hangindent
154 \caption@@par
155 #3\par}
156 \def\caption@fmt@default{\caption@fmt@normal}

158 % \DeclareCaptionLabelFormat{<name>}{<code with #1 and #2>}
159 % \caption@setlabelformat{<name>}

160 %

161 \newcommand*\DeclareCaptionLabelFormat[2]{%  bugfixed v3.0a
162 \global\expandafter\def\csname caption@lfmt@#1\endcsname##1##2{#2}}
163 \@onlypreamble\DeclareCaptionLabelFormat

164 %

165 \newcommand*\caption@setlabelformat[1]{%
166 \@ifundefined{caption@lfmt@#1}%
167  {\PackageError{caption}{Undefined caption label format `#1'}{\caption@eh}}%
168  {\expandafter\let\expandafter\caption@lfmt\csname caption@lfmt@#1\endcsname}}

169 %

170 % Pre-defined label formats

171 %

172 \DeclareCaptionLabelFormat{empty}{}
173 \DeclareCaptionLabelFormat{simple}{\bothIfFirst{#1}{\nobreakspace}#2}
174 \DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{\nobreakspace}(#2)}
175 \def\caption@lfmt@default{\caption@lfmt@simple}

176 %

177 % \DeclareCaptionLabelSeparator{<name>}{<code>}
178 % \caption@setlabelseparator{<name>}

179 %

180 \newcommand\DeclareCaptionLabelSeparator[2]{%  bugfixed v3.0a
181 \global\long\@namedef{caption@lsep@#1}{#2}}
182 \@onlypreamble\DeclareCaptionLabelSeparator

183 %

184 \newcommand*\caption@setlabelseparator[1]{%
185 \@ifundefined{caption@lsep@#1}%
186  {\PackageError{caption}{Undefined caption label separator `#1'}{\caption@eh}}%
187  {\expandafter\let\expandafter\caption@lsep\csname caption@lsep@#1\endcsname}}

188 %

189 % Pre-defined label separators

190 %

191 \DeclareCaptionLabelSeparator{none}{}
192 \DeclareCaptionLabelSeparator{colon}{: }
193 \DeclareCaptionLabelSeparator{period}{. }
194 \DeclareCaptionLabelSeparator{space}{ }
195 \DeclareCaptionLabelSeparator{quad}{\quad}
196 \DeclareCaptionLabelSeparator{newline}{\newline}
197 \DeclareCaptionLabelSeparator{widespace}{\hspace{1em plus .3em}}%  obsolete, do not use!
198 \def\caption@lsep@default{\caption@lsep@colon}

199 %

200 % \DeclareCaptionJustification{<name>}{<code>}
201 % \caption@setjustification{<name>}

202 %

203 \newcommand*\DeclareCaptionJustification[2]{%  bugfixed v3.0a
204 \global\@namedef{caption@hj@#1}{#2}}
205 \@onlypreamble\DeclareCaptionJustification

206 %

207 \newcommand*\caption@setjustification[1]{%
208 \@ifundefined{caption@hj@#1}%
209  {\PackageError{caption}{Undefined caption justification `#1'}{\caption@eh}}%
210  {\expandafter\let\expandafter\caption@hj\csname caption@hj@#1\endcsname}}

212 % Pre-defined justifications

213 %

214 \newcommand\caption@centerfirst{%
215 \edef\caption@normaladjust{%
216  \leftskip\the\leftskip
217  \rightskip\the\rightskip
218  \parfillskip\the\parfillskip\relax}%
219 \leftskip\z@\@plus -1fil%
220 \rightskip\z@\@plus 1fil%
221 \parfillskip\z@skip
222 \noindent\hskip\z@\@plus 2fil%
223 \@setpar{\@@par\@restorepar\caption@normaladjust}}
224 \newcommand\caption@centerlast{%
225 \leftskip\z@\@plus 1fil%
226 \rightskip\z@\@plus -1fil%
227 \parfillskip\z@\@plus 2fil\relax}

228 %

229 \DeclareCaptionJustification{justified}{}
230 \DeclareCaptionJustification{centering}{\centering}
231 \DeclareCaptionJustification{centerfirst}{\caption@centerfirst}
232 \DeclareCaptionJustification{centerlast}{\caption@centerlast}
233 \DeclareCaptionJustification{raggedleft}{\raggedleft}
234 \DeclareCaptionJustification{raggedright}{\raggedright}
235 \def\caption@hj@default{\caption@hj@justified}

236 %

237 % ragged2e package support (improved for v3.0b)
238 % ---------------------------------------------
239 \DeclareCaptionJustification{Centering}{%
240 \caption@ragged\Centering\centering}
241 \DeclareCaptionJustification{RaggedLeft}{%
242 \caption@ragged\RaggedLeft\raggedleft}
243 \DeclareCaptionJustification{RaggedRight}{%
244 \caption@ragged\RaggedRight\raggedright}

245 %

246 \newcommand*\caption@ragged[2]{%
247 \@ifundefined{caption\string#1}{%
248  \PackageWarning{caption}{%
249  Cannot locate the `ragged2e' package, therefore\MessageBreak
250  substituting \string#2 for \string#1\MessageBreak}%
251  \global\@namedef{caption\string#1}}{}%
252 #2}

253 %

254 \AtBeginDocument{\IfFileExists{ragged2e.sty}{%
255 \RequirePackage{ragged2e}\let\caption@ragged\@firstoftwo}{}}
256 % ---------------------------------------------

257 %

258 % \DeclareCaptionFont{<name>}{<code>}
259 % \caption@setfont{<command>}{<keyval-list of names>}

260 %

261 \newcommand\DeclareCaptionFont[2]{%  bugfixed v3.0a
262 \define@key{caption@fnt}{#1}[]{\g@addto@macro\caption@tempa{#2}}}
263 \@onlypreamble\DeclareCaptionFont

264 %

265 \newcommand*\caption@setfont[2]{%
266 \let\caption@tempa\@empty
267 \begingroup
268  \setkeys{caption@fnt}{#2}%
269 \endgroup
270 \expandafter\let\csname caption#1\endcsname\caption@tempa}

271 %

272 % Pre-defined fonts

273 %

274 \DeclareCaptionFont{default}{}

275 %

276 \DeclareCaptionFont{scriptsize}{\scriptsize}
277 \DeclareCaptionFont{footnotesize}{\footnotesize}
278 \DeclareCaptionFont{small}{\small}
279 \DeclareCaptionFont{normalsize}{\normalsize}
280 \DeclareCaptionFont{large}{\large}
281 \DeclareCaptionFont{Large}{\Large}

282 %

283 \DeclareCaptionFont{up}{\upshape}
284 \DeclareCaptionFont{it}{\itshape}
285 \DeclareCaptionFont{sl}{\slshape}
286 \DeclareCaptionFont{sc}{\scshape}
287 \DeclareCaptionFont{md}{\mdseries}
288 \DeclareCaptionFont{bf}{\bfseries}
289 \DeclareCaptionFont{rm}{\rmfamily}
290 \DeclareCaptionFont{sf}{\sffamily}
291 \DeclareCaptionFont{tt}{\ttfamily}

292 %

293 % Position (default(=bottom)/bottom/top/auto)
294 % ONLY DEFAULT, BOTTOM AND TOP ARE DOCUMENTED YET!

295 %

296 \newcommand*\caption@setposition[1]{%  improved v3.0a
297 \caption@ifinlist{#1}{t,top,above}{%
298  \let\caption@position\@firstoftwo
299 }{\caption@ifinlist{#1}{b,bottom,below,default}{%
300  \let\caption@position\@secondoftwo
301 }{\caption@ifinlist{#1}{a,auto}{%
302  \let\caption@position\@undefined
303 }{%
304  \PackageError{caption}{Undefined caption position `#1'}{\caption@eh}%
305 }}}}

306 %

307 % \captionsetup[<type>]{<keyval-list of options>}
308 % \caption@settype{<type>}

309 %

310 % If `type' is set, we simply save or append the option list,
311 % otherwise we `execute' it with \setkeys
312 % \changes{v3.0a}{17 Jan 04}{Missing percent added}

313 %

314 \def\captionsetup{\@ifnextchar[\caption@setuptype\caption@setup}
315 \def\caption@setuptype[#1]#2{%  bugfixed v3.0a
316 \@ifundefined{caption@typ@#1}%
317  {\@namedef{caption@typ@#1}{#2}}%
318  {\expandafter\l@addto@macro\csname caption@typ@#1\endcsname{,#2}}}

319 \def\caption@setup{\setkeys{caption}}

320 %

321 \def\caption@esetup#1{%
322 \edef\caption@tempa{\noexpand\caption@setup{#1}}%
323 \caption@tempa}

324 %

325 % Setting up caption type: Simply execute the saved option list
326 % (For use inside \@caption, \LT@makecaption etc.)

327 %

328 \def\caption@settype#1{%
329 \@ifundefined{caption@typ@#1}{}{%
330  \caption@esetup{\csname caption@typ@#1\endcsname}}}%
331 \let\caption@setfloattype\caption@settype%  new v3.0a

332 %

333 % \clearcaptionsetup{<type>}

334 %

335 \newcommand*\clearcaptionsetup[1]{\@nameundef{caption@typ@#1}}

336 %

337 % \showcaptionsetup[<package>]{<type>}
338 % (Note: The optional argument is not documented!)

339 %

340 \newcommand*\showcaptionsetup[2][]{%
341 \def\caption@tempa{#1}%
342 \ifx\caption@tempa\@empty
343  \def\caption@tempa{Caption\space}%
344 \else
345  \def\caption@tempa{#1 Caption\space}%
346 \fi
347 \GenericWarning{\caption@tempa}{%
348  \caption@tempa Info: KV list on `#2'\MessageBreak
349  Data: (%
350  \@ifundefined{caption@typ@#2}{%
351  % Empty -- print nothing.
352  }{%
353  \@nameuse{caption@typ@#2}%

354 }%

355  )}}

356 %

357 % Hooks (not documented yet...)

358 %

359 \newcommand\caption@beginhook{}
360 \newcommand\caption@endhook{}
361 \newcommand\AtBeginCaption{\l@addto@macro\caption@beginhook}
362 \newcommand\AtEndCaption{\l@addto@macro\caption@endhook}

363 %

364 % We declare options using the keyval package...

365 %

366 % \DeclareCaptionOption{<option>}{<code>}
367 % \DeclareCaptionOption*{<option>}{<code>}

368 %

369 \newcommand\DeclareCaptionOption{%
370 \@ifstar{\caption@declareoption\AtEndOfPackage}{\caption@declareoption\@gobble}}
371 \newcommand*\caption@declareoption[2]{%
372 #1{\undefine@key{caption}{#2}}\define@key{caption}{#2}}

373 \@onlypreamble\DeclareCaptionOption
374 \@onlypreamble\caption@declareoption

375 %

376 % ...and here comes the options

377 %

378 \DeclareCaptionOption{default}[]{%
379 \caption@setup{style=default,position=default,aboveskip=10pt,belowskip=0pt}}

380 %

381 \DeclareCaptionOption{style}{\caption@setstyle{#1}}
382 \DeclareCaptionOption{format}{\caption@setformat{#1}}
383 \DeclareCaptionOption{labelformat}{\caption@setlabelformat{#1}}
384 \DeclareCaptionOption{labelsep}{\caption@setlabelseparator{#1}}
385 \DeclareCaptionOption{labelseparator}{\caption@setlabelseparator{#1}}
386 \DeclareCaptionOption{justification}{\caption@setjustification{#1}}
387 \DeclareCaptionOption{size}{\caption@setfont{size}{#1}}% changed v3.0a
388 \DeclareCaptionOption{font}{\caption@setfont{font}{#1}}
389 \DeclareCaptionOption{labelfont}{\caption@setfont{labelfont}{#1}}
390 \DeclareCaptionOption{textfont}{\caption@setfont{textfont}{#1}}
391 \DeclareCaptionOption{margin}{\caption@setmargin{#1}}
392 \DeclareCaptionOption{width}{\caption@setwidth{#1}}
393 \DeclareCaptionOption{indent}[\leftmargini]{\setlength\captionindent{#1}}
394 \DeclareCaptionOption{indention}[\leftmargini]{\setlength\captionindent{#1}}
395 \DeclareCaptionOption{parindent}[\parindent]{\setlength\captionparindent{#1}}% changed v3.0b
396 \DeclareCaptionOption{hangindent}[0pt]{\setlength\captionhangindent{#1}}% changed v3.0b
397 \DeclareCaptionOption{parskip}[5pt]{\AtBeginCaption{\setlength\parskip{#1}}}

398 %

399 \DeclareCaptionOption{singlelinecheck}[1]{\caption@setbool{slc}{#1}}
400 \DeclareCaptionOption{aboveskip}{\setlength\abovecaptionskip{#1}}
401 \DeclareCaptionOption{belowskip}{\setlength\belowcaptionskip{#1}}
402 \DeclareCaptionOption{position}{\caption@setposition{#1}}
403 \DeclareCaptionOption{listof}{\caption@setbool{lof}{#1}}% new v3.0b

404 %

405 \DeclareCaptionOption{debug}{\def\caption@debug{#1}}

406 %

407 % Initialize options

408 %

409 \captionsetup{style=default,position=default,listof=1,debug=0}

410 %

411 % \caption@fixposition
412 % \caption@autoposition (new in 3.0b)

413 %

414 \newcommand\caption@fixposition{%
415 \ifx\caption@position\@undefined
416  \caption@autoposition
417 \fi}
418 \newcommand\caption@autoposition{% bugfixed v3.0a
419 \ifvmode
420  \ifodd\caption@debug\relax
421  \edef\caption@tempa{\the\prevdepth}%
422  \PackageInfo{caption}{\protect\prevdepth=\caption@tempa}%
423  \fi

424 %

425 %   \caption@setposition{\ifdim\prevdepth>-\p@ b\else t\fi}%
426  \ifdim\prevdepth>-\p@

427  \let\caption@position\@secondoftwo
428  \else
429  \let\caption@position\@firstoftwo
430  \fi
431 \else
432  \ifodd\caption@debug\relax
433  \PackageInfo{caption}{no \protect\prevdepth}%
434  \fi

435 %

436 %   \caption@setposition{b}%
437  \let\caption@position\@secondoftwo
438 \fi}

439 %

440 % \caption@iftop{<true-code>}{<false-code>}
441 % (If \caption@position is not set we assume a "bottom" position.)

442 %

443 \newcommand\caption@iftop{% bugfixed v3.0a
444 \ifx\caption@position\@firstoftwo
445  \expandafter\@firstoftwo
446 \else
447  \expandafter\@secondoftwo
448 \fi}

449 %

450 % Typeset caption

451 %

452 \newcommand\caption@make[2]{%
453 \caption@@make{\caption@lfmt{#1}{#2}}}

454 %

455 \newcommand\caption@@make[2]{%
456 \caption@beginhook

457 %

458 \caption@calcmargin
459 \advance\captionmargin by \captionindent
460 \advance\captionwidth by -\captionindent
461 \hskip\captionmargin
462 \vbox{\hsize=\captionwidth
463 % Bugfix v3.0b
464  \ifdim\captionindent=\z@\else
465  \hskip-\captionindent
466  \fi

467 %

468 % Special single-line treatment

469 %

470  \caption@ifslc{%
471  \ifx\caption@sls\@empty\else
472  \caption@beginslc
473  \sbox\@tempboxa{\caption@@@make{#1}{#2}}%
474  \ifdim\wd\@tempboxa >\hsize
475  \caption@endslc
476  \else
477  \caption@endslc
478  \caption@esetup\caption@sls
479  \fi
480  \fi}{}%

482  \captionsize\captionfont\strut
483  \caption@@@make{#1}{#2}}%

484 %

485 \caption@endhook
486 \global\caption@starfalse}

487 %

488 % Calculate \captionmargin & \captionwidth

489 %

490 \newcommand\caption@calcmargin{%
491 \ifcaption@width
492  \captionmargin\hsize
493  \advance\captionmargin by -\captionwidth
494  \divide\captionmargin by 2
495 \else
496  \captionwidth\hsize
497  \advance\captionwidth by -2\captionmargin
498 \fi

499 %

500 \ifodd\caption@debug\relax
501  \PackageInfo{caption}{\protect\hsize=\the\hsize,
502  \protect\margin=\the\captionmargin,
503  \protect\width=\the\captionwidth}%
504 \fi}

505 %

506 % Re-define anything which would disturb the single line check
507 % Bugfix v3.0b: re-definition of \label was missing here
508 % Improvement v3.0b: Better solution

509 %

510 \newcommand\caption@beginslc{%
511 \begingroup
512 \let\label\@gobble\let\@footnotetext\@gobble
513 \def\stepcounter##1{\advance\csname c@##1\endcsname\@ne\relax}}
514 % - or -
515 % \edef\caption@restore{%
516 %   \noexpand\setcounter{footnote}{\the\value{footnote}}%
517 %   \noexpand\setcounter{mpfootnote}{\the\value{mpfootnote}}}
518 \newcommand\caption@endslc{%
519 % \caption@restore
520 \endgroup}

521 %

522 % Typeset caption paragraph

523 %

524 \newcommand\caption@@@make[2]{%

525 %

526 % |\caption*|? Use no caption label and separator!

527 %

528 \ifcaption@star
529  \let\caption@lfmt\@gobbletwo
530  \let\caption@lsep\relax
531 \fi

532 %

533 % Empty text? Use no caption label separator!

534 %

535 \def\caption@tempa{#2}%
536 \def\caption@tempb{\ignorespaces}%
537 \ifx\caption@tempa\caption@tempb
538  \let\caption@tempa\@empty
539 \fi
540 \ifx\caption@tempa\@empty
541  \let\caption@lsep\relax
542 \fi

543 %

544 % Typeset the caption!

545 %

546 \def\caption@@par{%
547  \parindent\captionparindent\hangindent\captionhangindent}%
548 \@setpar{\@@par\caption@@par}\caption@@par

549 %

550 % (Bugfixed in v3.0b: \allowhyphens added)
551 \caption@hj\captionsize\captionfont
552 \caption@fmt{{\captionlabelfont#1}}%
553  {{\captionlabelfont\caption@lsep}}%
554  {{\captiontextfont\nobreak\hskip\z@skip#2\par}}}

11.2 Package

555 %\NeedsTeXFormat{LaTeX2e}[1994/12/01]
556 %\ProvidesPackage{caption}[2004/xx/xx v3.1 Customising captions (AS)]
557 %\RequirePackage{caption3}

558 %

559 % Add option for loading configuration file

560 %

561 \DeclareCaptionOption{config}[caption]{%
562 \InputIfFileExists{#1.cfg}{\typeout{*** Local configuration file
563  #1.cfg used ***}}%
564  {\PackageWarning{caption}{Configuration
565  file #1.cfg not found}}}

566 %

567 % \changes{v3.0a}{9 Jan 04}{Options `figureposition' and `tableposition' added}
568 \DeclareCaptionOption*{figureposition}{\captionsetup[figure]{position=#1}}%  new v3.0a
569 \DeclareCaptionOption*{tableposition}{\captionsetup[table]{position=#1}}%    new v3.0a

570 %

571 % Simulation of the old (caption v1.x) options:

572 %

573 \DeclareCaptionOption*{normal}[]{\caption@setformat{normal}}
574 \DeclareCaptionOption*{isu}[]{\caption@setformat{hang}}
575 \DeclareCaptionOption*{hang}[]{\caption@setformat{hang}}
576 \DeclareCaptionOption*{center}[]{\caption@setjustification{centering}}
577 \DeclareCaptionOption*{anne}[]{\caption@setjustification{centerlast}}
578 \DeclareCaptionOption*{centerlast}[]{\caption@setjustification{centerlast}}

579 %

580 \DeclareCaptionOption*{nooneline}[]{\caption@setbool{slc}{0}}

581 %

582 \DeclareCaptionOption*{scriptsize}[]{\def\captionfont{\scriptsize}}
583 \DeclareCaptionOption*{footnotesize}[]{\def\captionfont{\footnotesize}}
584 \DeclareCaptionOption*{small}[]{\def\captionfont{\small}}
585 \DeclareCaptionOption*{normalsize}[]{\def\captionfont{\normalsize}}
586 \DeclareCaptionOption*{large}[]{\def\captionfont{\large}}

587 \DeclareCaptionOption*{Large}[]{\def\captionfont{\Large}}

588 %

589 \DeclareCaptionOption*{up}[]{\l@addto@macro\captionlabelfont\upshape}
590 \DeclareCaptionOption*{it}[]{\l@addto@macro\captionlabelfont\itshape}
591 \DeclareCaptionOption*{sl}[]{\l@addto@macro\captionlabelfont\slshape}
592 \DeclareCaptionOption*{sc}[]{\l@addto@macro\captionlabelfont\scshape}
593 \DeclareCaptionOption*{md}[]{\l@addto@macro\captionlabelfont\mdseries}
594 \DeclareCaptionOption*{bf}[]{\l@addto@macro\captionlabelfont\bfseries}
595 \DeclareCaptionOption*{rm}[]{\l@addto@macro\captionlabelfont\rmfamily}
596 \DeclareCaptionOption*{sf}[]{\l@addto@macro\captionlabelfont\sffamily}
597 \DeclareCaptionOption*{tt}[]{\l@addto@macro\captionlabelfont\ttfamily}

598 %

599 \caption@setbool{ruled}{0}
600 \DeclareCaptionOption*{ruled}[]{\caption@setbool{ruled}{1}}

601 %

602 % Options for foreign package support

603 %

604 \newcommand*\DeclareCaptionPackage[1]{%
605 \caption@setbool{pkt@#1}{1}%
606 \DeclareCaptionOption*{#1}{\caption@setbool{pkt@#1}{##1}}}

607 %

608 % Compatible packages
609 % (new in v3.0b: The listings package)

610 %

611 \DeclareCaptionPackage{caption}
612 \DeclareCaptionPackage{float}
613 \DeclareCaptionPackage{listings}
614 \DeclareCaptionPackage{longtable}
615 \DeclareCaptionPackage{rotating}
616 \DeclareCaptionPackage{sidecap}
617 \DeclareCaptionPackage{supertabular}

618 %

619 \let\DeclareCaptionPackage\@undefined

620 %

621 % We process our options using the keyval package

622 %

623 \def\ProcessOptionsWithKV#1{% bugfixed v3.0a
624 \let\@tempc\relax
625 \let\caption@tempa\@empty
626 \@for\CurrentOption:=\@classoptionslist\do{%
627  \@ifundefined{KV@#1@\CurrentOption}%
628  {}%

629 {%

630  \edef\caption@tempa{\caption@tempa,\CurrentOption,}%
631  \@expandtwoargs\@removeelement\CurrentOption
632  \@unusedoptionlist\@unusedoptionlist

633 }% 634 }%

635 \edef\caption@tempa{%
636  \noexpand\setkeys{#1}{%
637  \caption@tempa\@ptionlist{\@currname.\@currext}%

638 }% 639 }%

640 \caption@tempa

641 % Bugfix, see <400D360C.9678329F@gmx.net> for details
642 \let\CurrentOption\@empty
643 \AtEndOfPackage{\let\@unprocessedoptions\relax}}
644 \ProcessOptionsWithKV{caption}
645 \let\ProcessOptionsWithKV\@undefined

646 %

647 % \captionof(*)

648 %

649 \def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}
650 \newcommand*\caption@of[2]{\def\@captype{#2}#1}

651 %

652 % ContinuedFloat

653 %

654 \providecommand\ContinuedFloat{%
655 \ifx\@captype\@undefined
656  \@latex@error{\noexpand\ContinuedFloat outside float}\@ehd
657 \else
658  \addtocounter{\@captype}{\m@ne}%
659 \fi}%

660 %

661 % \caption@floatname{<type>}
662 % \caption@thefloat{<type>}

663 %

664 \newcommand*\caption@floatname[1]{\@nameuse{#1name}}
665 \newcommand*\caption@thefloat[1]{\@nameuse{the#1}}

666 %

667 % \caption@letfloattype{<type>}
668 % (new in caption 3.0b)

669 %

670 \def\caption@letfloattype#1{%
671 \def\caption@setfloattype##1{%
672  \caption@settype{##1}\caption@settype{#1}}}

673 %

674 % \caption@begin{<type>} (changed in v3.0b)
675 % \caption@beginex{<type>}{<list entry>}
676 % \caption@end

677 %

678 \newcommand*\caption@begin[1]{%
679 \begingroup
680 \caption@setfloattype{#1}%
681 \@namedef{fnum@#1}{%
682  \caption@lfmt{\caption@floatname{#1}}{\caption@thefloat{#1}}}%

683 %

684 \caption@fixposition
685 \global\let\caption@fixedposition\caption@position

686 %

687 \caption@@begin{#1}}
688 \newcommand*\caption@beginex[1]{%
689 \caption@begin{#1}%
690 \caption@preparelof}
691 \newcommand*\caption@end{%
692 \caption@@end
693 \endgroup

694 %

695 \let\caption@position\caption@fixedposition}

696 %

697 % \caption@@begin{<type>}
698 % \caption@@end

699 %

700 \let\caption@@begin\@gobble%  new v3.0a
701 \let\caption@@end\@empty%     new v3.0a

702 %

703 % \caption@preparelof{<list entry>}

704 %

705 \newcommand*\caption@preparelof[1]{%  changed v3.0b
706 \caption@ifbool{lof}%
707  {\def\caption@tempa{#1}}%
708  {\let\caption@tempa\@empty}%
709 \ifx\caption@tempa\@empty
710  \def\addcontentsline##1##2##3{}%
711 \fi}

712 %

713 % CAPTION SUPPORT
714 % ===============

715 %

716 \caption@ifpkt@caption{

717 %

718 % \@makecaption{<label>}{<text>}
719 % Original code:
720 % \long\def\@makecaption#1#2{%
721 %   \vskip\abovecaptionskip
722 %   \sbox\@tempboxa{#1: #2}%
723 %   \ifdim \wd\@tempboxa >\hsize
724 %     #1: #2\par
725 %   \else
726 %     \global \@minipagefalse
727 %     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
728 %   \fi
729 %   \vskip\belowcaptionskip}

730 %

731 \renewcommand\@makecaption[2]{%
732  \caption@iftop{\vskip\belowcaptionskip}{\vskip\abovecaptionskip}%
733  \ifnum\caption@debug>1 %
734  \llap{$\caption@iftop\downarrow\uparrow$ }%
735  \fi
736  \caption@@make{#1}{#2}%
737  \caption@iftop{\vskip\abovecaptionskip}{\vskip\belowcaptionskip}}

738 %

739 \AtBeginDocument{%
740  \@ifundefined{cc@caption}{%

741 %

742 %     Define \caption* ...
743 %     (07/18/03: \global added, so this works with sidecap)

744 %

745  \def\caption@caption#1{%
746  \@ifstar{\global\caption@startrue\@ifnextchar[{#1}{#1[]}}{#1}}%

747 %

748  \let\caption@old\caption

749  \def\caption{\caption@caption\caption@old}%

750 %

751 %     Define \caption[]{...} ...

752 %

753  \let\caption@@old\@caption
754  \long\def\@caption#1[#2]#3{%
755  \caption@beginex{#1}{#2}%
756  \caption@@old{#1}[{#2}]{#3}%
757  \caption@end}%
758  }{%
759 %     Minimum captcont package support (bugfixed v3.0c)
760 %     --------------------------------
761  \PackageInfo{caption}{captcont package v2.0 detected}%
762  \def\caption@caption#1{#1}%  added v3.0c

763 }%

764 }}{}
765 \AtEndOfPackage{\let\caption@ifpkt@caption\@undefined}%  bugfixed v3.0a

766 %

767 % GENERIC PACKAGE SUPPORT
768 % =======================

769 %

770 \newcommand*\caption@ifpackage[2]{%
771 \let\next\@gobble

772 %

773 \caption@ifpkt@caption{%
774  \caption@ifbool{pkt@#1}{%
775  \@ifundefined{#2}%
776  {\let\next\AtBeginDocument}%
777  {\let\next\@firstofone}}{}%

778 %

779  \ifodd\caption@debug\relax
780  \edef\caption@tempa{%
781  \caption@ifbool{pkt@#1}{%
782  \@ifundefined{#2}{AtBeginDocument}{firstofone}%
783  }{gobble}}%
784  \PackageInfo{caption}{#1 = \caption@ifbool{pkt@#1}{1}{0} %
785  (\@ifundefined{#2}{not }{}loaded -> \caption@tempa)}%
786  \fi
787 }{}%

788 %

789 \@nameundef{caption@ifpkt@#1}%  bugfixed v3.0a
790 \next}
791 \AtEndOfPackage{\let\caption@ifpackage\@undefined}

792 %

793 % FLOAT PACKAGE SUPPORT
794 % =====================

795 %

796 \def\caption@setfloatposition{%
797 \caption@setposition{\@fs@iftopcapt t\else b\fi}}

798 %

799 \caption@ifpackage{float}{float@caption}{%
800 \ifx\float@caption\relax
801 \else
802  \PackageInfo{caption}{float package v1.2 (or newer) detected}%

804 % Note that this version of \captionof works only with float 1.3 (or newer)

805 %

806  \let\caption@of@float\@gobble
807  \renewcommand*\caption@of[2]{%
808  \@ifundefined{fst@#2}{}{%
809  \let\caption@of@float\@firstofone
810  \@nameuse{fst@#2}\@float@setevery{#2}}%

811 %

812  \def\@captype{#2}#1}%

813 %

814  \renewcommand*\caption@floatname[1]{%
815  \@nameuse{\@ifundefined{fname@#1}{#1name}{fname@#1}}}%

816 %

817  \let\caption@@float\float@caption
818  \long\def\float@caption#1[#2]#3{%
819  \caption@beginex{#1}{#2}%
820  \let\@fs@capt\caption@@make
821  \caption@@float{#1}[{#2}]{#3}%

822 %

823  \caption@of@float{%
824  \def\caption@@make##1##2{\unvbox\@floatcapt}%
825  \@makecaption{}{}}%
826  \caption@end}%

827 %

828  \renewcommand*\caption@setfloattype[1]{%  improved v3.0a
829  \caption@fixfloat@c{#1}%
830  \expandafter\ifx\csname @float@c@#1\endcsname\float@caption
831 %       This float is defined with \newfloat or \restylefloat, not with \restylefloat*
832  \expandafter\let\expandafter\caption@fst\csname fst@#1\endcsname
833  \edef\caption@fst{\noexpand\string\expandafter\noexpand\caption@fst}%
834  \edef\caption@fst{\noexpand\@gobblefour\caption@fst}%
835 %       \edef\caption@fst{\caption@fst}%
836 %       |\caption@fst| now contains the float style (e.g. ``ruled'')
837  \@ifundefined{caption@sty@\caption@fst}{}{\caption@setstyle\caption@fst}%
838  \caption@setfloatposition%  changed v3.0b
839  \fi
840  \caption@settype{#1}}%

841 %

842 % If you think this works fine, you are in a big error!
843 % The problem is that \newfloat and \restylefloat (of float 1.3) saves the
844 % *ACTUAL* definition of \@caption and \float@caption with \let, so our own
845 % \@caption (and of course our own \float@caption) will never been called if
846 % the \newfloat or \restylefloat takes place in the preamble of the document!

847 %

848 % So we have to correct this for ourself:
849 % We patch \caption again, this time we determine if the user has used
850 % \restylefloat or \restylefloat*. This is quite easy, if \@float@c@<captype>
851 % is the same as the original or our own definition of \float@caption, the
852 % user has used \restylefloat (and \float@caption should be used), otherwise
853 % we assume he has used \restylefloat* (and \@caption should be used).
854 % (This test will only fail if some other package re-defines \float@caption,
855 % too.)

856 %

857  \let\caption@float\caption
858  \def\caption{%
859  \ifx\@captype\@undefined
860  \@latex@error{\noexpand\caption outside float}\@ehd
861  \expandafter\@gobble
862  \else
863 %       Let's bring \@float@c@<captype> up-to-date!
864  \caption@fixfloat@c\@captype
865  \fi
866  \caption@float}%

867 %

868  \def\caption@fixfloat@c#1{%
869  \expandafter\let\expandafter\caption@tempa\csname @float@c@#1\endcsname
870  \ifx\caption@tempa\relax
871  \else\ifx\caption@tempa\float@caption
872  \else\ifx\caption@tempa\@caption
873  \else\ifx\caption@tempa\caption@@float
874  \ifodd\caption@debug\relax
875  \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\float@caption}%
876  \fi
877  \expandafter\let\csname @float@c@#1\endcsname\float@caption
878  \else
879  \ifodd\caption@debug\relax
880  \PackageInfo{caption}{\protect\@float@c@#1\space := \protect\@caption}%
881  \fi
882  \expandafter\let\csname @float@c@#1\endcsname\@caption
883  \fi\fi\fi\fi}%

884 %

885 \fi}

886 %

887 \caption@ifbool{ruled}{}{%
888 \DeclareCaptionStyle{ruled}{labelfont=bf,labelsep=space}}
889 \let\caption@ifruled\@undefined

890 %

891 % LISTINGS PACKAGE SUPPORT (new in 3.0b)
892 % ========================

893 %

894 \caption@ifpackage{listings}{lst@MakeCaption}{%
895 \ifx\lst@MakeCaption\relax
896 \else
897  \PackageInfo{caption}{listings package v1.2 (or newer) detected}%

898 %

899  \let\caption@lst@MakeCaption\lst@MakeCaption
900  \def\lst@MakeCaption#1{%
901  \let\caption@setfloattype\caption@settype
902  \def\caption@autoposition{\caption@setposition{#1}}%
903  \caption@begin{lstlisting}%
904  \caption@lst@MakeCaption{#1}%
905  \caption@end}%

906 %

907 \fi}

908 %

909 % LONGTABLE PACKAGE SUPPORT
910 % =========================

912 \caption@ifpackage{longtable}{LT@makecaption}{%
913 \ifx\LT@makecaption\relax
914 \else
915  \PackageInfo{caption}{longtable package v3.15 (or newer) detected}%

916 %

917 % Original code:
918 % \def\LT@makecaption#1#2#3{%
919 %   \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
920 %     % Based on article class "\@makecaption", "#1" is "\@gobble" in star
921 %     % form, and "\@firstofone" otherwise.
922 %     \sbox\@tempboxa{#1{#2: }#3}%
923 %     \ifdim\wd\@tempboxa>\hsize
924 %       #1{#2: }#3%
925 %     \else
926 %       \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
927 %     \fi
928 %     \endgraf\vskip\baselineskip}%
929 %   \hss}}}

930 %

931  \def\LT@makecaption#1#2#3{%
932  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\linewidth{%

933 %

934  \caption@letfloattype{longtable}%
935  \caption@begin{table}%
936  \ifdim\LTcapwidth=4in \else
937  \caption@setwidth\LTcapwidth
938  \fi
939  \caption@startrue#1\caption@starfalse
940  \caption@@make{#2}{#3}%
941  \endgraf\vskip\baselineskip
942 %          \endgraf\vskip\abovecaptionskip% always `position=top'
943  \caption@end}%

944 %

945  \hss}}}%

946 %

947 \fi}

948 %

949 % ROTATING PACKAGE SUPPORT
950 % ========================

951 %

952 \caption@ifpackage{rotating}{@rotcaption}{%
953 \ifx\@rotcaption\relax
954 \else
955  \PackageInfo{caption}{rotating package v2.0 (or newer) detected}%

956 %

957  \let\caption@rot\rotcaption
958  \def\rotcaption{\caption@caption\caption@rot}%

959 %

960  \let\caption@@rot\@rotcaption
961  \long\def\@rotcaption#1[#2]#3{%
962  \caption@beginex{#1}{#2}%
963  \caption@@rot{#1}[{#2}]{#3}%
964  \caption@end}%

966 % Original code:
967 % \long\def\@makerotcaption#1#2{%
968 %   \setbox\@tempboxa\hbox{#1: #2}%
969 %   \ifdim \wd\@tempboxa > .8\vsize
970 %     \rotatebox{90}{%
971 %     \begin{minipage}{.8\textheight}#1: #2\end{minipage}%
972 %     }\par
973 %   \else%
974 %     \rotatebox{90}{\box\@tempboxa}%
975 %   \fi
976 %   \hspace{12pt}%

977 % } 978 %

979  \long\def\@makerotcaption#1#2{%
980  \rotatebox{90}{%
981  \begin{minipage}{.8\textheight}%
982  \caption@@make{#1}{#2}%
983  \end{minipage}%
984  }\par
985  \hspace{12pt}}%

986 %

987 \fi}

988 %

989 % SIDECAP PACKAGE SUPPORT
990 % =======================

991 %

992 \caption@ifpackage{sidecap}{endSC@FLOAT}{%
993 \ifx\endSC@FLOAT\relax
994 \else
995  \PackageInfo{caption}{sidecap package v1.4d (or newer) detected}%

996 %

997 % First of all, we let sidecap use an actual definition of \caption:
998 % (This is only required for version 1.5d of the sidecap package.)

999 %

1000  \let\SC@caption=\caption

1001 %

1002 % Make \caption* and local settings (\captionsetup) work

1003 %

1004  \let\caption@SC@zfloat\SC@zfloat
1005  \def\SC@zfloat#1#2#3[#4]{%
1006  \caption@SC@zfloat{#1}{#2}{#3}[#4]%

1007 %

1008  \global\let\SC@CAPsetup\@empty
1009  \renewcommand\captionsetup[1]{\g@addto@macro\SC@CAPsetup{,##1}}%

1010 %

1011  \let\caption@old\caption
1012 %     \def\caption{\renewcommand\captionsetup[1]{}\caption@caption\caption@old}%
1013  \def\caption{\caption@caption\caption@old}%

1014 }% 1015 %

1016 % Before typesetting the caption, we set the captionmargin to zero
1017 % because the extra margin is only disturbing here.
1018 % (We don't need to take care about the caption position because

1019 %  the sidecap package set both \abovecaptionskip and \belowcaptionskip
1020 %  to a skip of zero anyway.)
1021 % Furthermore \SC@justify will override the caption justification, if set.

1022 %

1023 % Very old version (1.4): \SC@justify is not defined
1024 % Older versions (1.5): \SC@justify is \relax when not set
1025 % Newer versions (1.6): \SC@justify is \@empty when not set

1026 %

1027  \let\caption@endSC@FLOAT\endSC@FLOAT
1028  \def\endSC@FLOAT{%
1029  \caption@setmargin\z@

1030 %

1031  \@ifundefined{SC@justify}{}{%
1032  \ifx\SC@justify\@empty\else
1033  \let\caption@hj\SC@justify
1034  \let\SC@justify\@empty
1035  \fi}%

1036 %

1037  \caption@esetup\SC@CAPsetup
1038  \caption@letfloattype{SC\@captype}%

1039 %

1040  \caption@endSC@FLOAT}%

1041 %

1042 \fi}

1043 %

1044 % SUPERTABULAR PACKAGE SUPPORT
1045 % ============================

1046 %

1047 \def\caption@setSTposition{%
1048 \caption@setposition{\if@topcaption t\else b\fi}}

1049 %

1050 \caption@ifpackage{supertabular}{ST@caption}{%
1051 \ifx\ST@caption\relax
1052 \else
1053  \PackageInfo{caption}{supertabular package detected}%

1054 %

1055 % Original code:
1056 % \long\def\ST@caption#1[#2]#3{\par%
1057 %   \addcontentsline{\csname ext@#1\endcsname}{#1}%
1058 %                   {\protect\numberline{%
1059 %                       \csname the#1\endcsname}{\ignorespaces #2}}
1060 %   \begingroup
1061 %     \@parboxrestore
1062 %     \normalsize
1063 %     \if@topcaption \vskip -10\p@ \fi
1064 %     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
1065 %     \if@topcaption \vskip 10\p@ \fi
1066 %   \endgroup}

1067 %

1068 \let\caption@ST\ST@caption
1069 \long\def\ST@caption#1[#2]#3{\par%  bugfixed v3.0a
1070  \caption@letfloattype{supertabular}%
1071  \let\caption@fixposition\caption@setSTposition
1072  \caption@beginex{#1}{#2}%

1073  \addcontentsline{\csname ext@#1\endcsname}{#1}%
1074  {\protect\numberline{%
1075  \csname the#1\endcsname}{\ignorespaces #2}}%
1076  \@parboxrestore
1077  \normalsize
1078  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
1079  \caption@end}%

1080 %

1081 \fi}

1082 %

1083 % KOMA-SCRIPT CLASSES SUPPORT (new in 3.0a)
1084 % ===========================

1085 %

1086 % \changes{v3.0a}{18 Jan 04}{Minimum adaption to KOMA-Script}
1087 \AtBeginDocument{\let\scr@caption\caption}

References

[1] Frank Mittelbach and Michel Goossens: The L^{A}TEX Companion (2nd. Ed.), Addison-Wesley, 2004.

[2] Anselm Lingnau: An Improved Environment for Floats, 2001/11/08

[3] Carsten Heinz: The Listings Package, 2004/02/13

[4] David Carlisle: The longtable package, 2000/10/22

[5] Sebastian Rahtz and Leonor Barroca: A style option for rotated objects in L^{A}TEX, 1997/09/26

[6] Rolf Niepraschk und Hubert Gäßlein: The sidecap package, 2003/06/06

[7] Steven D. Cochran: The subfig package, 2004/01/16

[8] Johannes Braams und Theo Jurriens: The supertabular environment, 2002/07/19