List of Figures - how to add caption label
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}
To achieve what you're aiming for without loading the tocloft
package, one has to patch an instruction in LaTeX's internal \@caption
macro and redefine the internal macros \l@figure
and \l@table
.
The following MWE shows how to do this; note that the patching is done with the command \patchcmd
provided by the etoolbox
package. (If, for some reason, you don't want to use the \patchcmd
instruction, you will need to copy and paste the entire definition of \@caption
from the file latex.ltx
into your preamble and replace the string \csname the#1\endcsname
with \csname fnum@#1\endcsname:
, leaving the other instructions unchanged.)
\documentclass{article}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@caption}{\csname the#1\endcsname}{\csname fnum@#1\endcsname:}{}{}
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{4.5em}} % default for 3rd arg: 2.3em
\let\l@table\l@figure % as in article.cls
\makeatother
\begin{document}
\listoffigures
\listoftables
\begin{figure}[h]
\caption{A figure}
\centering xyz
\end{figure}
\begin{table}[h]
\caption{Some table}
\centering abc
\end{table}
\end{document}
When you caption your figure, there's an optional argument that's designed for the list of figures.
\caption[short title]{Long caption describing the figure.}
This will display the short title as the title in the list of figures, and the long caption as the actual caption of your figure. It is perfectly acceptable for these both to be the same.
It is designed this way as many figures, particularly in scientific publications have long captions describing everything that is in the figure. All of this wouldn't fit into the list of figures, so there is a separate title for that purpose.
It is optional because you don't need it if you are not including a list of figures.