5

I am submitting an article to a journal with the following requirement:

Figure legends should be listed one after the other, as part of the text document, separate from the figure files.

Currently, my figure captions are in the format

\caption[short caption]{full caption}

And I only want the full caption to appear.

Can I insert the complete figure legends in a list of figures, and exclude them from the figure itself?

(Edit: without changing the behavior of table captions?)

2 Answers2

2

This seems be what you're after...

Using the caption package you can modify captions by removing the label separator. Additionally, I've redefined \caption so you only need to specify a single (mandatory) argument. (Edit: Moved redefinition to after \begin{document}.) oldcaption gives the default behavior of caption.

\documentclass{article}
\usepackage{caption}% http://ctan.org/pkg/caption
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\DeclareCaptionTextFormat{none}{} \captionsetup[figure]{labelsep=none,textformat=none}

\begin{document}

\tableofcontents
\listoffigures
\section{First section}
\lipsum[1]
\begin{figure}[ht]
  \centering \includegraphics{image1}
  \caption[Unused first legend]{This is a first legend}
\end{figure}
\lipsum[2]
\begin{table}[ht]
\caption[a, b, and c]{The first $3$ letters of the alphabet}
\centering
\begin{tabular}{lll}
  \hline 
  a & b & c \\ 
  \hline
\end{tabular}
\end{table}
\lipsum[1]
\begin{figure}[ht]
  \centering \includegraphics{image2}
  \caption[Unused second legend]{This is a second legend}
\end{figure}
\lipsum[3]
\end{document}

enter image description here

lipsum provides filler text, while the demo option to graphicx is just meant for this MWE example, since it doesn't have images included. Captions are just typeset as Figure <num>, while the actual figure caption is included in the "List of Figures".

Werner
  • 603,163
  • 1
    The example code will issue the warning "Package caption Warning: \caption will not be redefined since it's already redefined by a document class or package which is unknown to the caption package.". So IMHO one better put the redefinition of \caption inside \AtBeginDocument. –  Oct 05 '11 at 05:25
  • @AxelSommerfeldt: Agreed, or move the \renewcommand{\caption}{...} to after \begin{document}. – Werner Oct 05 '11 at 05:29
  • An alternative option would be dropping the redefinition of \caption and using \DeclareCaptionTextFormat{none}{} \captionsetup{labelsep=none,textformat=none} instead. –  Oct 05 '11 at 05:30
  • Werner, if you move the \renewcommand after \begin{document} you should move the \LetLtxMacro, too. Otherwise your code will drop the redefinition of \caption done by the caption package. –  Oct 05 '11 at 05:59
  • @Werner this is a great start, but your example does not work when using \caption[short caption]{long caption}. Any advice on how to fix this? – David LeBauer Oct 05 '11 at 20:34
  • @David: In \caption[short caption]{long caption}, what would short caption and long caption be used for? At the moment, I've completely disregarded short caption and only put long caption in the LoF. Where would you want to put short caption? Or is it just so your original code can compile without problem, since that's easily fixable? – Werner Oct 05 '11 at 20:42
  • @Werner it is just so my original code can compile without problem. – David LeBauer Oct 05 '11 at 20:45
  • 1
    @David: I've updated my code. The only change is actually: renewcommand{\caption}[2][]{\oldcaption[#2]{}} which now allows for an optional first argument to \caption[..]{...}. It is not used at all in the document (it's discarded). – Werner Oct 05 '11 at 21:01
  • 1
    The actual version 3.2c of the caption package has a new option textformat=empty, so \usepackagelabelsep=none,textformat=empty]{caption} should do the trick, too. –  Oct 12 '11 at 16:25
  • @David: That's not a problem. You can erase your recent comments to keep this area clean. I'll do the same. – Werner Jul 31 '12 at 19:50
1

In the following solution the list of captions is printed at the end of the document. It has the advantage that it's sufficient to comment out the added code in order to have the normal version of the document printed. In the final list only "long captions" will be printed, while the normal list will have the short ones.

\documentclass[a4paper]{article}
\usepackage{lipsum}

\makeatletter
\usepackage{shorttoc,letltxmacro,etoolbox}
\LetLtxMacro{\ORIcaption}{\caption}
\renewcommand{\caption}{\@dblarg{\x@caption}}
\def\x@caption[#1]#2{\ORIcaption[\shortcaption{#1}\longcaption{#2}]{#2}}
\DeclareRobustCommand{\shortcaption}{}
\DeclareRobustCommand{\longcaption}{}
\let\ORIlistoffigures\listoffigures
\renewcommand{\listoffigures}{%
  \begingroup
    \def\shortcaption##1{##1} \def\longcaption##1{}
    \anothertableofcontents[lof]{\jobname}{\listfigurename}{1}
  \endgroup}
\newcommand{\listofcaptions}{\newpage
  \pagestyle{empty}
  \begingroup
    \def\shortcaption##1{} \def\longcaption##1{##1}%
    \def\listfigurename{Captions to figures}%
    \def\l@figure##1##2{\@dottedtocline{1}{1.5em}{2.3em}{##1}{}}%
    \patchcmd{\@dottedtocline}{\hbox{.}}{}{}{}%
    \listoffigures
    \endgroup}
\AtEndDocument{\listofcaptions}
\makeatother

\begin{document}

\listoffigures

\lipsum[1]

\begin{figure}
X
\caption{This has only a long caption}
\end{figure}

\begin{figure}
Y
\caption[This short one]{This has also a short caption}
\end{figure}

\end{document}
egreg
  • 1,121,712