You could use the tocloft
package; an example:
\documentclass{book}
\usepackage{tocloft}
\newlength{\mylen}
\renewcommand{\cftfigpresnum}{\figurename\enspace}
\renewcommand{\cftfigaftersnum}{:}
\settowidth{\mylen}{\cftfigpresnum\cftfigaftersnum}
\addtolength{\cftfignumwidth}{\mylen}
\begin{document}
\listoffigures
\begin{figure}[!ht]
\centering
\rule{2cm}{2cm}
\caption{test figure one}
\label{fig:test1}
\end{figure}
\begin{figure}[!ht]
\centering
\rule{2cm}{2cm}
\caption{test figure two}
\label{fig:test2}
\end{figure}
\end{document}
If you want tocloft
to use default LaTeX formatting (so it won't "mess up" for example the layout of your table of contents and so on) you can use the titles option of the package:
\usepackage[titles]{tocloft}
This is a way. Let's define a new command \doublecaption
to be used when you want that behavior in the LoF:
\makeatletter
\def\doublecaption{%
\ifx\@captype\@undefined
\@latex@error{\noexpand\caption outside float}\@ehd
\expandafter\@gobble
\else
\refstepcounter\@captype
\expandafter\@firstofone
\fi
{\@dblarg{\@doublecaption\@captype}}%
}
\long\def\@doublecaption#1[#2]#3{%
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #3\newline#2}}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
The definition is taken from the normal \caption
and modified to fit your needs.
In the tocloft
settings, remove
\renewcommand\cftfigaftersnumb{\\}
and add
\newlength\mylength
\settowidth\mylength{\cftfigpresnum}
\addtolength\cftfignumwidth{\mylength}
MWE:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage[titles]{tocloft}
\addtocontents{lof}{\cftpagenumbersoff{figure}}
\renewcommand\listfigurename{Figure Legends}
\renewcommand\cftfigpresnum{\bfseries Figure }
\renewcommand\cftfigaftersnum{\bfseries :}
%\renewcommand\cftfigaftersnumb{\\}
\renewcommand{\cftdotsep}{\cftnodots}
\setlength\cftbeforefigskip{12pt}
\newlength\mylength
\settowidth\mylength{\cftfigpresnum}
\addtolength\cftfignumwidth{\mylength}
\makeatletter
\def\doublecaption{%
\ifx\@captype\@undefined
\@latex@error{\noexpand\caption outside float}\@ehd
\expandafter\@gobble
\else
\refstepcounter\@captype
\expandafter\@firstofone
\fi
{\@dblarg{\@doublecaption\@captype}}%
}
\long\def\@doublecaption#1[#2]#3{%
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #3\newline#2}}%
\begingroup
\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
\begin{document}
\lipsum[1]
\begin{figure}[ht]
\centering \includegraphics{image1}
\doublecaption[Normally a much longer legend for the first figure.]{Title for first fig}
\end{figure}
\lipsum[2]
\begin{figure}[ht]
\centering \includegraphics{image2}
\caption{Title for second fig}
\end{figure}
\clearpage
\listoffigures
\end{document}
Output:
EDIT
Please next time, post examples with all relevant loaded packages...
To let it work with subcaption
, we'll define two commands:
\doublecaption
, to be used in figures with no subfigures.
\doublesubcaption
, to be used in figures with subfigures.
Substitute the above code starting with \makeatletter
and ending with \makeatother
with this one (require the etoolbox
package):
\makeatletter
\let\doublecaption\caption%
\patchcmd{\doublecaption}%
{\@caption}%
{\@doublecaption}%
{}%
{}%
\let\@doublecaption\@caption%
\patchcmd{\@doublecaption}%
{\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}}%
{\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #3\newline#2}}}%
{}%
{}%
\let\doublesubcaption\doublecaption%
\patchcmd{\doublesubcaption}%
{\refstepcounter\@captype}%
{\relax}%
{}%
{}%
\makeatother
MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{subcaption}
\usepackage[titles]{tocloft}
\addtocontents{lof}{\cftpagenumbersoff{figure}}
\renewcommand\listfigurename{Figure Legends}
\renewcommand\cftfigpresnum{\bfseries Figure }
\renewcommand\cftfigaftersnum{\bfseries : }
\renewcommand{\cftdotsep}{\cftnodots}
\setlength\cftbeforefigskip{12pt}
\newlength\mylength
\settowidth\mylength{\cftfigpresnum}
\addtolength\cftfignumwidth{\mylength}
\makeatletter
\let\doublecaption\caption%
\patchcmd{\doublecaption}%
{\@caption}%
{\@doublecaption}%
{}%
{}%
\let\@doublecaption\@caption%
\patchcmd{\@doublecaption}%
{\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}}%
{\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #3\newline#2}}}%
{}%
{}%
\let\doublesubcaption\doublecaption%
\patchcmd{\doublesubcaption}%
{\refstepcounter\@captype}%
{\relax}%
{}%
{}%
\makeatother
\begin{document}
\lipsum[1]
\begin{figure}[ht]
\centering \includegraphics{image1}
\doublecaption[Normally a much longer legend for the first figure.]{Title for first fig}
\end{figure}
\lipsum[2]
\begin{figure}[ht]
\centering
\begin{subfigure}{0.45\textwidth}
\includegraphics{image2}
\caption{Case one}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\includegraphics{image3}
\caption{Case two}
\end{subfigure}
\doublesubcaption[Not very long legend for fig with subfigs.]{Title for fig with subfigs}
\end{figure}
\lipsum[3]
\clearpage
\listoffigures
\end{document}
Output:
Best Answer
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:
\addcaptionsshorttrue
to use only the short captions\addcaptionsshortfalse
to use the long entriesI've tested this with
book
,article
,memoir
andscrbook
classes.In addition, the redefined
\caption
command checks first if the\@captype
macro expands tofigure
, 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
fromcaption
package.