3

I have a long thesis in the works, and I am not 100% sure what the requirements are for the display of the List of Figure section. Currently, all my figures have a long caption and a short caption:

\caption[Short Caption]{Long Caption}

and i would like to be able to switch all the captions in my \listoffigures between the two options in case I decide on one style or another.

  • There are reasons for long and short captions which have nothing to do with esthetics. Your best bet is to replace \caption with a custom macro which selects one of two arguments to use as the only argument for \caption. – John Kormylo Oct 13 '16 at 2:50
  • Define and use something like \mycaption and then redefine it if/when needed. – jon Oct 13 '16 at 2:51
  • Thanks. This is an easy enough fix. Can you explain what reasons there are for long and short captions? – Necarion Oct 13 '16 at 23:44
  • 1
    @Necarion: Short captions should be used if the long description would be too long for the LoF (etc.) -- long captions do not look very nice there! In addition, a short caption can be as informative as a long caption too. – user31729 Jan 2 '17 at 11:45
2

This code enables either only long captions in the LoF or the regular short ones, as given in the optional argument to the \caption macro (well, actually the [...] delimited argument of \@caption)

I added a switch to control the behaviour:

  • Say \addcaptionsshorttrue to use only the short captions
  • Say \addcaptionsshortfalse to use the long entries

I've tested this with book, article, memoir and scrbook classes.

In addition, the redefined \caption command checks first if the \@captype macro expands to figure, i.e. it is a figure caption. Otherwise every caption (using the \@captype mechanism) would write either long or short entry to its relevant ToC.

No change is done for \captionof from caption package.


\documentclass{book}

\usepackage{caption}
\usepackage{xparse}

\usepackage{pgffor}


\makeatletter
\let\latex@@caption\caption

\newif\ifallcaptionsshort% toggle switch
\allcaptionsshorttrue% Use the short ones


\RenewDocumentCommand{\caption}{+o+m}{%
  \def\@figcaptype{figure}
  \ifx\@captype\@figcaptype
  \ifallcaptionsshort
  \IfValueTF{#1}{% 
    \latex@@caption[#1]{#2}%
  }{%
    \latex@@caption[#2]{#2}% No [#1] given, use the long caption then!
  }
  \else
  \latex@@caption[#2]{#2}%
  \fi
  \else
  \IfValueTF{#1}{% 
    \latex@@caption[#1]{#2}%
  }{%
    \latex@@caption[#2]{#2}% No [#1] given, use the long caption then!
  }
  \fi
}
\makeatother
\begin{document}


\allcaptionsshortfalse% Use the long ones
\listoffigures
\listoftables

\foreach \x in {1,...,10}{%
\begin{figure}
  \caption[Short title \x]{Some long dummy figure caption \x}
\end{figure}

\begin{table}
  \caption[Short table \x]{Some long dummy table caption \x}
\end{table}
}


\end{document}

enter image description here

2

(This answer is too long, to fit in a comment)

Meaning of Floats

The meaning of a float-environment is, to have some content (tables, images, etc.) which are to massive, to be incorporated in the normal text. For example, think of a table, containing the results of a long lasting chemical experiment. There will be lines and lines of say pH-values, for every minute of a week a line.

You won't put those data into your normal text, as it would be to disgusting for the gentle reader, to dig through all the data, before being able, to read your next conclusion.

The normal way is, to describe in the text, what you have done, how the environment was suited, which staring values you used and so on. Than you decribe in a kind of summary, what was going on the long time, the experiment was running, and what you finally got as result. Than, you will draw your conclusions. ...

The gentle reader may believe your description. In that case, he does not need to see your table data. But he may also disapprove with your conclusions. In that case, he has to consult the table to find the detail, that you haven't noticed ...

So we do have two parts of the same story: your table with the first hand data and your written text with conclusions.

A good document should be set up, that you could either look at only the table data or only the text, to get all the desired information you need.

Meaning of the \caption

The \caption command is the tool, to enable a table (in our case) float, to become a single source of information. The caption above your table should contain all the needed information, to understand the table data. If you copy the table from \begin{table}\caption{...} to \end{table}, paste it in a blank sheet of paper and present this to someone having not read your remaining document, he must be able, to exactly know, what you have done, to get the data in that table!

Therefore the curly braces in your \caption-command must contain all data, that are important to the generation the table content! This is the essential function of the \caption-command!

Of course, this will make the \caption-content rather long and clumsy. Much to long, to, to be incorporated into the List of Tables, where it would clutter up the function of that list.

Meaning of the List of Tables/Figures

The meaning of the List of Tables or List of Figures is, to enable a consulting reader, to find the table or figure he needs to consult, in a fast and reliable way. When looking into the List of Tables, he doesn't want to know about the details, that where responsible for the data generation. He wants to know, on which page the table with the TNT-reaction resides. And he wants to be sure, to not consult the table with the titration of NaCl by accident.

Conclusion

In my opinion, the curly braces of the \caption-command must contain as much informations, that can be given to that specific float, whereas the square brackets should only contain that least information, that is needed, to doubtlessly identify the location of the desired float in your document.

You shouldn't mix up this targets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.