4

Basically I want this:

Abbildungsverzeichnis

Abbildung 1: somecaptiontextxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx.........................................................34

Abbildung 1 is the name of the figure. It equals figure 1, figure 2 etc. Abbildungsverzeichnis means list of figures. I didn't translate it in English, because the picture at the bottom is all in German, which shows the actual state of my list of figures.

But the code I used:

\usepackage[titles]{tocloft}

\newlength{\mylen}

\renewcommand{\cftfigpresnum}{\figurename\enspace} 
\renewcommand{\cftfigaftersnum}{:}
\settowidth{\mylen}{\cftfigpresnum\cftfigaftersnum}
\addtolength{\cftfignumwidth}{\mylen}

produced this:

enter image description here

Thanks in advance.

5

A possible solution using tocloft:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[titles]{tocloft}
\usepackage{graphicx}

\newlength\mylen
\cftsetindents{figure}{0em}{0em}

\let\orignumberline\numberline
\let\origlistoffigures\listoffigures

\renewcommand\listoffigures{%
  \renewcommand\numberline[1]{%
    \settowidth\mylen{\figurename\enspace:##1\enspace}%
    \orignumberline{\figurename\enspace##1:\enspace\hspace{-\mylen}}\hspace{\mylen}%
  }%
  \origlistoffigures
  \let\numberline\orignumberline
}

\begin{document}

\listoffigures
\clearpage

\section{Test}

\begin{figure}
\centering
\includegraphics[height=3cm]{example-image-a}
\caption{this is just a caption for a test figure, we add some more text here so the caption will span several lines}
\end{figure}

\end{document} 

enter image description here

If you are willing to change to titletoc instead of tocloft, here's how it's done:

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{titletoc}
\usepackage{graphicx}

\titlecontents{figure}
  [0em]
  {}
  {\figurename\enspace\thecontentslabel:\enspace}
  {}
  {\titlerule*[1pc]{.}\contentspage}

\begin{document}

\listoffigures

\begin{figure}
\centering
\includegraphics[height=3cm]{example-image-a}
\caption{this is just a caption for a test figure, we add some more text here so the caption will span several lines}
\end{figure}

\end{document} 

An image of the resulting LoF:

enter image description here

  • I used the second suggestion with titletoc and it works perfectly fine. Is there the possibility to add some vertical space between the elements of the list for better readability? At the moment, the elements of the figure list are too close to each other. – NuCore Jul 22 '14 at 11:48
  • @NuCore Sure. Use the last optional argument to add the desired space, as in \titlecontents{figure} [0em] {} {\figurename\enspace\thecontentslabel:\enspace} {} {\titlerule*[1pc]{.}\contentspage}[\vskip10pt] – Gonzalo Medina Jul 22 '14 at 13:30
1

You would have to adjust the way tocloft constructs the LoF entry by modifying the margin lengths that are set. Below is a redefinition of \l@figure from tocloft to provide you with the necessary output:

\makeatletter
\renewcommand*{\l@figure}[2]{%
  \ifnum \c@lofdepth >\z@
    \vskip \cftbeforefigskip
    {%\leftskip \cftfigindent\relax
     \rightskip\z@%\rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent\z@%\parindent \cftfigindent\relax
    \@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftfignumwidth\relax
     \let\@cftbsnum \cftfigpresnum
     \let\@cftasnum \cftfigaftersnum
     \let\@cftasnumb \cftfigaftersnumb
     \null\nobreak%\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftfigfont #1}\nobreak
     \cftfigfillnum{#2}}%
   \fi
  }
\makeatother

The commented parts have been changed.

enter image description here

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{graphicx}

\usepackage[titles]{tocloft}

\makeatletter
\renewcommand*{\l@figure}[2]{%
  \ifnum \c@lofdepth >\z@
    \vskip \cftbeforefigskip
    {%\leftskip \cftfigindent\relax
     \rightskip\z@%\rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent\z@%\parindent \cftfigindent\relax
    \@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftfignumwidth\relax
     \let\@cftbsnum \cftfigpresnum
     \let\@cftasnum \cftfigaftersnum
     \let\@cftasnumb \cftfigaftersnumb
     \null\nobreak%\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftfigfont #1}\nobreak
     \cftfigfillnum{#2}}%
   \fi
  }
\makeatother

\newlength{\mylen}

\renewcommand{\cftfigpresnum}{\figurename\enspace} 
\renewcommand{\cftfigaftersnum}{:\enspace}
\settowidth{\mylen}{\cftfigpresnum\cftfigaftersnum}
\addtolength{\cftfignumwidth}{\mylen}

\begin{document}

\listoffigures

\begin{figure}
  \centering
  \includegraphics[height=3cm]{example-image-a}
  \caption{this is just a caption for a test figure, we add some more text here so the caption will span several lines}
\end{figure}

\end{document}

Keeping the \rightskip \@tocrmarg option leaves you with the following output:

enter image description here

You could also use etoolbox to redefine \l@figure, if needed. It won't be much cleaner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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