6

I am using tocloft and subcaption package, and I would like to suppreess page numbers and dot line for subfigures in LOF.

I know, if one uses tocloft and subfigure package, this can be done with the next command:

\cftpagenumbersoff{subfigure}

So, I would like to emulate this command with subcaption package. The point is that I have all the subfigures done with subcaption package, and I would not like to change the code of all them.

2 Answers 2

9

Here's one possibility which enables you to use all of tocloft features for subfigure entries when using the subcaption package; in particular, you can suppress the page numbers and the leaders (the dots from the entry to the page number):

\documentclass{article}
\usepackage[list=true]{subcaption}
\usepackage{tocloft}

\setcounter{lofdepth}{2}
\cftpagenumbersoff{subfigure}
\makeatletter
\newcommand\cftsubtabdotsep{\cftdotsep}
\newcommand\cftsubfigfont{\normalfont}
\newcommand\cftsubfigpresnum{}
\newcommand\cftsubfigaftersnum{}
\newcommand\cftsubfigaftersnumb{}
\newcommand\cftsubfigleader{\hfill}
\newcommand\cftsubfigpagefont{\normalfont}
\newcommand\cftsubfigafterpnum{}
\providecommand{\toclevel@subfigure}{1}
\renewcommand*\l@subfigure[2]{%
  \ifnum \c@lofdepth > \toclevel@subfigure
    \vskip \cftbeforesubfigskip
    {\leftskip \cftsubfigindent\relax
     \rightskip \@tocrmarg
     \parfillskip -\rightskip
     \parindent \cftsubfigindent\relax\@afterindenttrue
     \interlinepenalty\@M
     \leavevmode
     \@tempdima \cftsubfignumwidth\relax
     \let\@cftbsnum \cftsubfigpresnum
     \let\@cftasnum \cftsubfigaftersnum
     \let\@cftasnumb \cftsubfigaftersnumb
     \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
     {\cftsubfigfont #1}\nobreak
     \cftsubfigfillnum{#2}}%
  \fi
  }%
\newlength\cftbeforesubfigskip
  \setlength\cftbeforesubfigskip{\z@ \@plus.2\p@}
\newlength\cftsubfigindent
  \setlength\cftsubfigindent{3.8em}
\newlength\cftsubfignumwidth
  \setlength\cftsubfignumwidth{2.5em}
\renewcommand{\cftsubfigfillnum}[1]{%
  {\cftsubfigleader\hfill}\par
}
\makeatother

\begin{document}

\listoffigures

\begin{figure}
\begin{subfigure}{.5\linewidth}
\centering
A
\caption{test subfigure A}
\label{sfig:testa}
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\centering
B
\caption{test subfigure B}
\label{sfig:testb}
\end{subfigure}
\caption{Test figure}
\label{fig:testa}
\end{figure}

\begin{figure}
\begin{subfigure}{.5\linewidth}
\centering
C
\caption{test subfigure C}
\label{sfig:testc}
\end{subfigure}%
\begin{subfigure}{.5\linewidth}
\centering
D
\caption{test subfigure D}
\label{sfig:testd}
\end{subfigure}
\caption{Test figure}
\label{fig:testb}
\end{figure}

\end{document}

enter image description here

1
  • It works perfectly.
    – Gitano
    Aug 23, 2013 at 3:14
0

The tocloft package can offer a bunch of useful macro to tweak the formatting of subfigures if you pass the option subfigure to it.

In this case the package will assume that you use the subfigure package and that the counters lofdepth and lotdepth are defined by the subfigure package.

But if you want to use packages tocloft with subcaption instead of subfigure the said counters are not created by tocloft nor subcaption packages.

Just load the packages and define these counters to make everything works properly.

\usepackage{subcaption}
\usepackage[subfigure]{tocloft}
\newcounter{lofdepth}
\newcounter{lotdepth}

% here you have access to all tocloft subfig macro
\setlength{\cftsubfigindent}{01emem}
\setlength{\cftsubfignumwidth}{3em}
\renewcommand{\cftfigfont}{\sffamily}
\renewcommand{\cftfigpagefont}{\ttfamily}

You must log in to answer this question.

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