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?
[Tex/LaTex] How to make the list of figures use an automatically shortened version of the caption
captionstable of contents
Related Solutions
I would go with the caption
package; using the list=no
option you can suppress the entries in the LoF for a particular figure or for a group of figures; using the plain
format (for the subfigures) you can achieve the desired format for their captions; an example (if this change should only affect selected subfigures, remove the line \captionsetup[subfigure]{format=plain}
from the preamble and include it in the corresponding figure
environment(s)):
\documentclass[11pt,a4paper,BCOR10mm,DIV11,toc=listof]{scrbook}
\usepackage[caption=false, font=footnotesize, justification=RaggedRight]{subfig}
\usepackage{caption}
\captionsetup[subfigure]{format=plain}
\begin{document}
\listoffigures
\chapter{Test}
\begin{figure}
\caption{A figure with a caption and its entry in the LoF}
\end{figure}
\begin{figure}
% this particular figure will be numbered and labeled but won't have entry in the LoF
\captionsetup{list=no}
\caption{A figure with a caption without entry in the LoF}
\end{figure}
\begin{figure}
\caption{Another figure with a caption and its entry in the LoF}
\end{figure}
\begin{figure}
\centering
\subfloat[text text text text text text text text text This is left aligned with no indent.]%
{%
\label{fig:a}%
\rule{0.48\linewidth}{0.48\linewidth}
}%
\subfloat[text text text text text text text text text This is left aligned with no indent.]%
{%
\label{fig:b}%
\rule{0.48\linewidth}{0.48\linewidth}
}%
\caption[Bla]{A figure with two subfigures}
\label{fig:example}
\end{figure}
\chapter{Test two}
\captionsetup[figure]{list=no}
% all figures from this point on will be numbered and labeled but won't have entry in the LoF
\begin{figure}
\caption{A second figure with a caption without entry in the LoF}
\end{figure}
\begin{figure}
\caption{A third figure with a caption without entry in the LoF}
\end{figure}
\end{document}
Moreover, if it's not too late (there's no deadline involved), I would suggest you to change to the subcaption
package instead of subfig
.
EDIT: I've added the adjustemnts needed to have the requested format for the subfigure captions.
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}
Best Answer
An alternative implementation, shortening the caption in the lof while typesetting it...