3

In my document, figures in the main text have the caption "Figure" whilst those in the appendices have the caption "Appendix". I would like this to be reflected in my list of figures. Can I make the code \renewcommand{\cftfigpresnum}{Figure } vary to do this?

The following output is produced from the MWE below - I would like "Figure 2 Figure in Appendices" to be "Appendix 2 Figure in appendices".

enter image description here

\documentclass[a4paper, 12pt]{report}

\usepackage{tocloft}

\setlength{\cftfignumwidth}{6 em}
\renewcommand{\cftfigpresnum}{Figure }

\begin{document}

\listoffigures

\begin{figure}[ht]
\caption{Figure in main text}
\end{figure}

\renewcommand{\figurename}{Appendix}

\begin{figure}[ht]
\caption{Figure in appendices}
\end{figure}

\end{document}

1 Answer 1

3

The \ctffigpresnum macro could be used for this, however it must be written directly to the .lof file with \addtocontents{lof}{...} (see the code below) The \protect statements are needed to preserve the fragile commands during the writing process.

I've used \addtolength{\cftfignumwidth}{...} instead of explicitly setting it to a fix length with \setlength.

\documentclass[a4paper, 12pt]{report}


\usepackage{tocloft}

\addtolength{\cftfignumwidth}{4em}
\renewcommand{\cftfigpresnum}{Figure }

\begin{document}

\listoffigures

\begin{figure}[ht]
\caption{Figure in main text}
\end{figure}

\renewcommand{\figurename}{\appendixname}
\addtocontents{lof}{\protect\renewcommand{\protect\cftfigpresnum}{\appendixname\ }}

\begin{figure}[ht]
\caption{Figure in appendices}
\end{figure}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .