2

I added figure label to the LoF but the caption is hanged, this is my MWE:

\documentclass{book}
\usepackage{amsmath}
%i tried this solution
\usepackage[titles]{tocloft}
\cftsetindents{figure}{0em}{2.5em}
\cftsetindents{table}{0em}{2.5em}
\begin{document}
{%                    to add label/ figure  to LoF
\let\oldnumberline\numberline%
\renewcommand{\numberline}{\figurename~\oldnumberline}%

\listoffigures%

}
\begin{figure}
\caption{stuff The second  instruction, i.e., the resetting of the indentation amount for the entries in the List of Tables, isn't strictly necessary for your}
\label{fig:first9}
 \end{figure}

\begin{figure}
\caption{stufThe second  instruction, i.e., the resetting of the indentation amount for the entries in the List of Tables, isn't strictly necessary for you}
\label{fig:first11}
\end{figure}

\end{document}

enter image description here

1 Answer 1

2

The package tocloft offers commands to achieve what you want without modifying the meaning of \numberline.

You can simply use \listoffigures and add the following lines to your preamble:

\renewcommand\cftfigpresnum{\figurename~}
\newlength\mylength
\settowidth\mylength{\cftfigpresnum}
\addtolength\cftfignumwidth{\mylength}

MWE:

\documentclass{book}
\usepackage{amsmath}
%i tried this solution
\usepackage[titles]{tocloft}
\cftsetindents{figure}{0em}{2.5em}
\renewcommand\cftfigpresnum{\figurename~}
\newlength\mylength
\settowidth\mylength{\cftfigpresnum}
\addtolength\cftfignumwidth{\mylength}

\cftsetindents{table}{0em}{2.5em}
\begin{document}

\listoffigures

\begin{figure}
\caption{stuff The second  instruction, i.e., the resetting of the indentation amount for the entries in the List of Tables, isn't strictly necessary for your}
\label{fig:first9}
 \end{figure}

\begin{figure}
\caption{stufThe second  instruction, i.e., the resetting of the indentation amount for the entries in the List of Tables, isn't strictly necessary for you}
\label{fig:first11}
\end{figure}

\end{document} 

Output:

enter image description here

If you need the same behaviot for \listoftables add the following lines, as well:

\renewcommand\cfttabpresnum{\tablename~}
\settowidth\mylength{\cfttabpresnum}
\addtolength\cfttabnumwidth{\mylength}

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.