Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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! –  zeroth Feb 27 '12 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 Feb 29 '12 at 4:24

2 Answers 2

up vote 3 down vote accepted

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}
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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