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.

I'm using the caption package. In the List-Of-Figures I get only the numbers, but I also want to have the prefix. It currently looks like that:

List of Figures
1 Caption of Figure 1........1
2 Caption of Figure 2........9

And I want it to look like:

List of Figures
Figure 1: Caption of Figure 1...1
Figure 2: Caption of Figure 2...9

The same format is already used for the captions themselves.

share|improve this question

3 Answers 3

up vote 15 down vote accepted

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}
share|improve this answer
    
This works well, except that tocloft seems to ruin the format of LOF and LOT. But I will figure that out. Thank you very much. –  MiKa Mar 7 '11 at 18:00

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.

share|improve this answer
    
Just noticed that you're using the caption package, what I have described is the default. I would guess that the syntax for the caption package is similar (if not exactly the same). –  Dom Mar 7 '11 at 16:45
1  
a tip: If you indent lines by 4 spaces, then they're marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). –  Hendrik Vogt Mar 7 '11 at 17:17
    
Thank you very much @Dom, but that's not what I'm looking for. –  MiKa Mar 7 '11 at 18:00
    
Sorry @MiKa, just re-read, and realised I hadn't understood the question, oh well. Thanks for the pointer on how to make it look like code @Hendrik Vogt. –  Dom Mar 7 '11 at 21:49
    
no problem, luckily somebody found a solution to my problem. Thanks for trying!!! –  MiKa Mar 8 '11 at 12:08

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}

enter image description here

share|improve this answer
    
Why would want not to use tocloft? –  Martin Schröder Jan 23 '12 at 20:03

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.