The ccaption package^{∗}

Peter Wilson Catholic University of America^{†}

             Now at peter.r.wilson@boeing.com

1998/10/14

Abstract

The ccaption package provides for ‘continuation’ captions and also for an ‘anonymous’ caption (a legend) that can be used in any float environment.

Contents

1 Introduction 1

2 The ccaption package 2

3 The package code 3

List of Tables

1 A multi-part table . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Another table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1 Introduction

Some publishers require that documents that include multi-part tables use a continuation caption on all but the first part of the multi-part table. For the times where such a table is specified by the author as a set of tables, the ccaption package provides a simple ‘continuation’ caption command to meet this requirement. It also provides a facility for an ‘anonymous’ caption which can be used in any float environment.

These facilities were originally developed in support of a suite for typesetting ISO international standard [Wil96], but they are generally applicable. This manual Table 1: A multi-part table

∗This file has version number v2.1, last revised 1998/10/14.

†This work was originally performed as a Guest Researcher at the National Institute of Standards and Technology.

just a single line 1

is typeset according to the conventions of the L^{A}TEX docstrip utility which enables the automatic extraction of the L^{A}TEX macro source files [GMS94].

Section 2 provides a short overview of the commands in the package and shows some examples of their use. The implementation is given in Section 3.

2 The ccaption package

The L^{A}TEX \caption command is used within either a table or a figure environment to produce appropriately labelled and numbered captions. The captioning text may also be listed via a \listoftables and/or listoffigures command.

\contcaption The \contcaption{⟨text⟩} command can be used to put a ‘continuation’ or ‘concluded’ caption into a float environment. It neither increments the float number nor makes any entry into a float listing, but it does repeat the numbering of the previous \caption command.

Table 1 illustrates the use of the \contcaption command. The table was produced from the following code.

   \begin{table}
   \centering
   \caption{A multi-part table} \label{tab:m}
   \begin{tabular}{lc} \hline
    just a single line & 1 \\ \hline
   \end{tabular}
   \end{table}
   \begin{table}
   \centering
   \contcaption{Continued}
   \begin{tabular}{lc} \hline
    just a single line & 2 \\ \hline
   \end{tabular}
   \end{table}
   \begin{table}
   \centering
   \contcaption{Concluded}
   \begin{tabular}{lc} \hline
    just a single line & 3 \\ \hline
   \end{tabular}
   \end{table}

\legend The \legend{⟨text⟩} command can be used to put an anonymous caption into a float environment.

Table 1: Continued

just a single line 2

Table 1: Concluded

just a single line 3

For example, the following code was used to produce the two-line table 2. The \legend command can be used within a float independently of any \caption command.

   \begin{table}
   \centering
   \caption{Another table} \label{tab:legend}
   \begin{tabular}{lc} \hline
    A legendary table & 5 \\
    with two lines    & 6 \\ \hline
   \end{tabular}
   \legend{The legend}
   \end{table}

Title legend

This is a marginal note with a legend.

Captioned floats are usually thought of in terms of the table and figure environments. There can be other kinds of float. As perhaps a more interesting example, the following code produces the titled marginal note which should be displayed near here.

     \marginpar{\legend{Title legend}
                This is a marginal note with a legend.}

You can even

Legend in running text

use the \legend command in running text, as has been done in this sentence, but I’m not sure why one might want to do that as L^{A}TEX already provides the center environment.

\abovelegendskip  Correspondingly to the \abovecaptionskip and \belowcaptionskip com-

\belowlegendskip mands associated with the \caption command, the spacing before and after a legend is controlled by the \abovelegendskip and \belowlegendskip commands. If necessary, these can be modified via the \setlength command.

Table 2: Another table

A legendary table 5
with two lines  6

The legend

3 The package code

Announce the name and version of the package, which requires L^{A}TEX 2ε.

1 ⟨∗usc⟩

 2 \NeedsTeXFormat{LaTeX2e}
 3 \ProvidesPackage{ccaption}[1998/10/14 v1.1 Continuation and anonymous captioning]

\contcaption \contcaption{⟨text⟩} is a user-level command. It is a simplified version of the normal \caption command as it doesn’t have to deal with numbering or list of … entries.

 4 \newcommand{\contcaption}{\@contcaption\@captype}

\@contcaption This is the workhorse for the \contcaption command. In turn, it uses the \@makecaption command (defined in the usual classes) to do most of its work. It uses the number of the previous \caption command in the same type of float and its implementation includes much of the code used in the L^{A}TEX \caption command.

 5 \long\def\@contcaption#1#2{%
 6 \begingroup
 7  \@parboxrestore
 8  \if@minipage
 9  \@setminipage
10  \fi
11  \normalsize
12  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #2}\par
13 \endgroup}

\abovelegendskip \belowlegendskip These two lengths control the vertical spacing before and after a legend. We will give these values such that a legend will ocupy an integral number of lines.

14 \newlength{\abovelegendskip}
15 \setlength{\abovelegendskip}{0.5\baselineskip}
16 \newlength{\belowlegendskip}
17 \setlength{\belowlegendskip}{\abovelegendskip}

\legend The command is called as \legend{⟨text⟩}. It is intended to be used in a float

environment for an ‘anonymous’ caption.

The implementation is similar to the \caption command.

18 \newcommand{\legend}[1]{%
19 \par
20 \begingroup
21  \@parboxrestore
22  \if@minipage
23  \@setminipage
24  \fi
25  \normalsize
26  \@makelegend{\ignorespaces #1}\par
27 \endgroup}

\@makelegend The implementation of this command is similar to that of the \@makecaption command in the standard classes.

28 \long\def\@makelegend#1{%
29 \vskip\abovelegendskip
30 \sbox\@tempboxa{#1}%
31 \ifdim \wd\@tempboxa >\hsize
32  #1\par
33 \else
34  \global \@minipagefalse
35  \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
36 \fi
37 \vskip\belowlegendskip}

The end of this package.

38 ⟨/usc⟩

References

[GMS94] Michel Goossens, Frank Mittelbach, and Alexander Samarin. The LaTeX Companion. Addison-Wesley Publishing Company, 1994.

[Wil96] Peter R. Wilson. LaTeX for standards: The LaTeX package files user manual. NIST Report NISTIR, June 1996.

Index

Numbers written in italic refer to the page where the corresponding entry is described, the ones underlined to the code line of the definition, the rest to the code lines where the entry is used.

Symbols

\@captype . . . . . . . . . 4

\@contcaption . . . . 4, \underline{5}
\@makecaption . . . . . 12
\@makelegend . . . . 26, \underline{28}
\@minipagefalse . . . 34
\@parboxrestore . . 7, 21
\@setminipage . . . . 9, 23

A

\abovelegendskip . .

. . . . . . . 3, \underline{14}, 29

B

\baselineskip . . . . . 15

                          \belowlegendskip . .

. . . . . . . 3, \underline{14}, 37

C

                          \contcaption . . . . . 2, \underline{4}

\csname . . . . . . . . . . 12

E

                          \endcsname . . . . . . . 12

H \hb@xt@ . . . . . . . . . . 35

I

                          \if@minipage . . . . . 8, 22

                                                   \ignorespaces . . . 12, 26

L \legend . . . . . . . . . 2, \underline{18}

N

                                                   \normalsize . . . . . 11, 25

P

                                                   \ProvidesPackage . . . 3

S \sbox . . . . . . . . . . . . 30