[Tex/LaTex] How to make the list of figures use an automatically shortened version of the caption

captionstable of contents

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?

Best Answer

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}
Related Question