10

I use the caption and subcaption package as shown in the example below:

\documentclass{article}

\usepackage{caption}
\usepackage{subcaption}

\captionsetup[subfigure]{list=true}

\begin{document}
\listoffigures

\begin{figure}[!ht]
\centering
\begin{subfigure}{.5\linewidth}
\centering
A
\caption{test subfigure}
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\centering
B
\caption{another test subfigure}
\end{subfigure}
\caption{A figure with subfigures}
\end{figure}

\end{document}

How can i remove the page numbers of the subfigures from the list of figures? (subfigures are in my document always on the same page as the "main figure")

PS: tocloft seems not to be compatible with the caption/subcaption packages

Jonas
  • 641

1 Answers1

8

This trick seems to work.

First of all, load the the tocloft package with the option subfigure, as if you were using the subfigure package.

\usepackage[subfigure]{tocloft}

Now, since in this case tocloft doesn't declare the counter lofdepth, we declare it explicitely and set it to 2:

\newcounter{lofdepth}
\setcounter{lofdepth}{2}

At this point, we simply add the line

\cftpagenumbersoff{subfigure}

to remove page numbers for subfigures.

Complete MWE:

\documentclass{article}

%\usepackage{caption}
\usepackage{subcaption}

\captionsetup[subfigure]{list=true}

\usepackage[subfigure]{tocloft}

\newcounter{lofdepth}
\setcounter{lofdepth}{2}

\cftpagenumbersoff{subfigure}


\begin{document}
\listoffigures

\clearpage

\begin{figure}[!ht]
\centering
\begin{subfigure}{.5\linewidth}
\centering
A
\caption{test subfigure}
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\centering
B
\caption{another test subfigure}
\end{subfigure}
\caption{A figure with subfigures}
\end{figure}

\end{document} 

Output:

enter image description here

karlkoeller
  • 124,410