8

Many of my captions are quite long and appear as 5 or more lines in the list of figures. To save me the effort of using the optional argument in the caption are there any packages that can produce the list of figures with just the first line and some sort of symbol to indicate that that is not the full caption?

2
  • 1
    That sounds really dangerous as you then still have to go through the first line in order to check the meaning of the words, i.e. it would seem to me that what you want to do is defying the purpose of a List of Figures. Even though your inquiry as a TeX question is intriguing!
    – nickpapior
    Commented Feb 27, 2012 at 21:33
  • Instead of one long caption that you truncate could you give the figure a quick name/description and a longer caption, ex. Figure 1: Aeolipile of Hero of Alexandria, schematic illustration of the 1st century AD steam engine consisting of a heat source, water reservoir and rotating sphere with protruding steam nozzles. Then just have the short name "Aeolipile of Hero of Alexandria" in the list of figures.
    – s0rce
    Commented Feb 29, 2012 at 4:24

2 Answers 2

3

An alternative implementation, shortening the caption in the lof while typesetting it...

enter image description here

\documentclass{article}
\showboxdepth1
\showboxbreadth100
\makeatletter
\long\def\l@figure#1#2{%
\setbox0\vbox{%
\def\lpx{\interlinepenalty-\@M}%
\advance\hsize -1em
\@dottedtocline{1}{1.5em}{2.3em}{\aftergroup\lpx#1bbbb}{#2}}%
\ifdim\ht0>\baselineskip
\begingroup
\vbadness\maxdimen
\setbox2=\vsplit0to \baselineskip
\setbox4\vbox{%
\unvbox2
\global\setbox1\lastbox}%
\endgroup
\noindent\hbox to \linewidth{\unhbox1\unskip!!%
\dotfill\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #2}%
%\kern\@tocrmarg
}%
\else
\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}%
\fi
}
\begin{document}

\listoffigures

\begin{figure}[!b]
\caption{One one one a  longish caption.}
\end{figure}



\begin{figure}[!b]
\caption{A short caption.}
\end{figure}


\begin{figure}[!b]
\caption{This one is a very  very  very  very  very  very  very 
 very  very  very  very  very long caption.}
\end{figure}


\def\z{even longer than before }
\begin{figure}[!b]
\caption{Hmmm \z\z\z. Very long caption. More \z\z\z.}
\end{figure}

\end{document}
11

You can try and truncate the caption argument, but be warned that typographically this will look very poor.

enter image description here

You will need to add two packages, one is the caption package and the other the truncate package. we define a new command \Caption to be used as:

\Caption[optional width spec.]{caption text ..............}

Variations are also possible and I leave that for you to experiment with.

\documentclass{article}
\usepackage{truncate}
\usepackage{caption}
\begin{document}
\listoffigures
\DeclareRobustCommand\Caption[2][130pt]{\captionof{figure}{\truncate{#1}{#2}}}
\begin{figure}
\Caption{This is my famous half a kilometer long caption that has been truncated}
\end{figure}
\begin{figure}
\Caption{This is my famous half a kilometer long caption that has not been truncated}
\end{figure}
\end{document}

You can disable the effects later by redeclaring the \Caption command as follows:

 \DeclareRobustCommand{\Caption}[2][]{\captionof{figure}{#2}}

I can think of many other ways to provide the input and this will ultimately depend, if one needs to leave the shortened version permanently or not.

2
  • I implemented your solution but it worked for some of the figures. I mean it truncated most of the figure captions in the list of figures but some were still being displayed almost completely. Commented Sep 25, 2015 at 16:38
  • You may have to to compile 2-3 times.
    – yannisl
    Commented Sep 26, 2015 at 2:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .