4

In my document, I have several figures spread throughout and some of them consist of subfigures without captions. If I want to print a List of Figures (LOF), then these "captionless" subfigures appear in the form:

 1. Figure 1: <Caption>
     * a.
     * b.
     * c.

Now, that's pointless. However, I still want to include the subfigures in the LoF, since many of them do have proper captions.

To remove the "captionless" subfigure entries from the LoF, I tried this solution suggested by @Hertbert and it seems to work partially. That is, the required entries are indeed removed from the LoF, however this solution appears to add some additional vertical spacing between the two figure entries, as illustrated in the image given below:

LoF unwanted extra space

My question is how to get rid of this extra vertical space between the two LoF entries without affecting other entries containing subfigures?

Here's my Minimal Working Example (MWE):

\documentclass[a4paper,oneside]{report}
\usepackage[demo]{graphicx}         %% To get demo figures
\usepackage{showframe}              %% Shows the actual page layout
\usepackage[list=true]{subcaption}  %% alternative for subfigure
                                    %% To get subfloats listed in list of figures, you
                                    %% must load the subcaption package with [list=true]
                                    %% option!
%%\usepackage{subfigure}            %% deprecated package!
\usepackage[subfigure]{tocloft}     %% A trick for tocloft+subcaption combo.
                                    %% This option is required if, and only if,
                                    %% the tocloft and subfigure packages are being used
                                    %% together. The two packages can be specifed in any
                                    %% order. - From the tocloft package documentation
                                    %% (dated 2013/05/02)

\newcounter{lofdepth}               %% Declare new LoF depth counter
\newcounter{lotdepth}               %% Declare new LoT depth counter
\setcounter{lofdepth}{2}            %% Set new LoF depth counter to include subfigures
%%\setcounter{lofdepth}{1}          %% If subfigures are't needed in LoF

%% Adding horizontal space between LoF numbers and entry text
\renewcommand{\cftfignumwidth}{1in}                         %% Exaggerated width!
\renewcommand{\cftsubfignumwidth}{1in}                      %% Exaggerated width!

%% Indentation for LoF entry numbers
\renewcommand{\cftfigindent}{0em}
\renewcommand{\cftsubfigindent}{2.25em}

%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}

%% Customisation of subfig numbers in the LoF entries
\renewcommand{\cftsubfigpresnum}{[\hspace*{0.5mm}}
\renewcommand{\cftsubfigaftersnum}{{}.\hspace*{0.5mm}]}

%% Figure LoF entries in bold
\renewcommand{\cftfigfont}{\bfseries}
\renewcommand{\cftfigpagefont}{\bfseries}
\renewcommand{\cftfigleader}{\bfseries\cftdotfill{\cftfigdotsep}}

%% To switch-off page numbers of subfigure LoF entries
\cftpagenumbersoff{subfigure}

\begin{document}

\tableofcontents
   \cleardoublepage
\listoffigures
   \cleardoublepage
\listoftables
   \cleardoublepage

\chapter{CHAPTER 1}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{First SUB-FLOAT}
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{Second SUB-FLOAT}
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption{Third SUB-FLOAT}
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 1}
   \end{figure}

\cleardoublepage    

    \section{Section 1}

        \begin{table}[h]    
          \begin{center}
            \vspace*{1.5in}
              \scalebox{1.25}{  
                \begin{tabular}{|c|c|}
                  \hline
                   Mineral & Color \\
                  \hline
                  \hline                                    
                  Ruby & red \\
                  \hline
                  \hline                            
                  Sapphire & blue \\
                  \hline
                \end{tabular}   
              }         
          \end{center}
            \caption{Demo Table 1}
            \vspace*{50pt}
        \end{table}                 

\subsection{Subsection 1}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 2}
   \end{figure}

\cleardoublepage        

\chapter{CHAPTER 2}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{First SUB-FLOAT}
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{Second SUB-FLOAT}
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption{Third SUB-FLOAT}
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 3}
   \end{figure}

\cleardoublepage

    \section{Section 2}

        \begin{table}[h]    
          \begin{center}
            \vspace*{1.5in}
              \scalebox{1.25}{  
                \begin{tabular}{|c|c|}
                  \hline
                   Fruit & Color \\
                  \hline
                  \hline                                    
                  Apple & red \\
                  \hline
                  \hline                            
                  Banana & Yellow \\
                  \hline
                \end{tabular}   
              }         
          \end{center}
            \caption{Demo Table 2}
            \vspace*{50pt}
        \end{table}

\subsection{Subsection 2}

\cleardoublepage        

\end{document}

Removing the tocloft added vertical skips from the preamble (see below) does not change observed behaviour of this code!

%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}

Note: This may appear like a duplicate question, however solutions to similar problems aren't really useful in this case. A solution suggested here by @barbara-beeton is based on ams document classes and is also erroneous, to which a resolution wasn't found after the question was closed; whereas a solution given here by @steven-b-segletes is based on removing all appendix -related figures and tables and is therefore not applicable in this case.

Any help would be greatly appreciated. Thanks!


Update: This is just F.Y.I. Just found another way to exclude a certain figure/subfigure/table for whatever reason, without affecting other entries. Include \captionsetup[<float-type>]{list=no} %% <float-type> = figure/subfigure/table just before the figure you wish to exclude and restore it back again after that figure with \captionsetup[<float-type>]{list=yes} and viola! it's gone from the list! (Source: Excluding items from list-of-figures / list-of-tables)

  • 2
    That is the default behaviour that between two entries which are from different chapters are devided by an additional space. It is the same as for the table of contents. – user2478 Sep 29 '16 at 12:45
  • 1
    If you add \chapter before “Demo Figure 2”, you'll notice the “extra space” is also added between it and “Demo Figure 1”. If you want to remove this extra space, you have to patch \chapter not to issue \addtocontents{lof}{\protect\addvspace{10\p@}}. – egreg Sep 29 '16 at 13:42
  • @Herbert But, to my eye it looks a bit odd. Can it be reduced somehow? – Amar Sep 29 '16 at 13:44
  • @egreg Thanks! But, how to do that? – Amar Sep 29 '16 at 13:45
5

The standard behavior of report and book is to separate, in the list of figures and tables, items pertaining to different chapters by a vertical space and this is the space you see.

If you want a tight list of figures without this separation, it's easy to patch \chapter:

\usepackage{etoolbox}

%% remove the \addvspace{10\p@} in LOF and LOT
\makeatletter
\patchcmd{\@chapter}
  {\addtocontents{lof}{\protect\addvspace{10\p@}}}% tokens to search
  {}% tokens to replace
  {}{}
\patchcmd{\@chapter}
  {\addtocontents{lot}{\protect\addvspace{10\p@}}}% tokens to search
  {}% tokens to replace
  {}{}
\makeatother

Full code

\documentclass[a4paper,oneside]{report}
\usepackage{etoolbox}               %% for patching commands
\usepackage[demo]{graphicx}         %% To get demo figures
\usepackage{showframe}              %% Shows the actual page layout
\usepackage[list=true]{subcaption}  %% alternative for subfigure
                                    %% To get subfloats listed in list of figures, you
                                    %% must load the subcaption package with [list=true]
                                    %% option!
%%\usepackage{subfigure}            %% deprecated package!
\usepackage[subfigure]{tocloft}     %% A trick for tocloft+subcaption combo.
                                    %% This option is required if, and only if,
                                    %% the tocloft and subfigure packages are being used
                                    %% together. The two packages can be specifed in any
                                    %% order. - From the tocloft package documentation
                                    %% (dated 2013/05/02)

\newcounter{lofdepth}               %% Declare new LoF depth counter
\newcounter{lotdepth}               %% Declare new LoT depth counter
\setcounter{lofdepth}{2}            %% Set new LoF depth counter to include subfigures
%%\setcounter{lofdepth}{1}          %% If subfigures are't needed in LoF

%% Adding horizontal space between LoF numbers and entry text
\renewcommand{\cftfignumwidth}{1in}                         %% Exaggerated width!
\renewcommand{\cftsubfignumwidth}{1in}                      %% Exaggerated width!

%% Indentation for LoF entry numbers
\renewcommand{\cftfigindent}{0em}
\renewcommand{\cftsubfigindent}{2.25em}

%% Vertical skips for LoF entries
\renewcommand{\cftbeforefigskip}{12pt}
\renewcommand{\cftbeforesubfigskip}{8pt}

%% Customisation of subfig numbers in the LoF entries
\renewcommand{\cftsubfigpresnum}{[\hspace*{0.5mm}}
\renewcommand{\cftsubfigaftersnum}{{}.\hspace*{0.5mm}]}

%% Figure LoF entries in bold
\renewcommand{\cftfigfont}{\bfseries}
\renewcommand{\cftfigpagefont}{\bfseries}
\renewcommand{\cftfigleader}{\bfseries\cftdotfill{\cftfigdotsep}}

%% To switch-off page numbers of subfigure LoF entries
\cftpagenumbersoff{subfigure}

%% remove the \addvspace{10\p@} in LOF and LOT
\makeatletter
\patchcmd{\@chapter}
  {\addtocontents{lof}{\protect\addvspace{10\p@}}}% tokens to search
  {}% tokens to replace
  {}{}
\patchcmd{\@chapter}
  {\addtocontents{lot}{\protect\addvspace{10\p@}}}% tokens to search
  {}% tokens to replace
  {}{}
\makeatother

\begin{document}

\tableofcontents
   \cleardoublepage
\listoffigures
   \cleardoublepage
\listoftables
   \cleardoublepage

\chapter{CHAPTER 1}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{First SUB-FLOAT}
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{Second SUB-FLOAT}
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption{Third SUB-FLOAT}
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 1}
   \end{figure}

\cleardoublepage    

    \section{Section 1}

        \begin{table}[h]    
          \begin{center}
            \vspace*{1.5in}
              \scalebox{1.25}{  
                \begin{tabular}{|c|c|}
                  \hline
                   Mineral & Color \\
                  \hline
                  \hline                                    
                  Ruby & red \\
                  \hline
                  \hline                            
                  Sapphire & blue \\
                  \hline
                \end{tabular}   
              }         
          \end{center}
            \caption{Demo Table 1}
            \vspace*{50pt}
        \end{table}                 

\subsection{Subsection 1}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption[]{}                      %% captionless subfigure
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 2}
   \end{figure}

\cleardoublepage        

\chapter{CHAPTER 2}

   \begin{figure}[!ht]
   \vspace*{-20pt}
      \centering
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{First SUB-FLOAT}
            %\label{fig:demo1}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering
            \caption{Second SUB-FLOAT}
            %\label{fig:demo2}
         \end{subfigure}
         \begin{subfigure}{0.56\textwidth}
            \includegraphics{}
            \centering  
            \caption{Third SUB-FLOAT}
            %\label{fig:demo3}
         \end{subfigure}
   \caption{Demo Figure 3}
   \end{figure}

\cleardoublepage

    \section{Section 2}

        \begin{table}[h]    
          \begin{center}
            \vspace*{1.5in}
              \scalebox{1.25}{  
                \begin{tabular}{|c|c|}
                  \hline
                   Fruit & Color \\
                  \hline
                  \hline                                    
                  Apple & red \\
                  \hline
                  \hline                            
                  Banana & Yellow \\
                  \hline
                \end{tabular}   
              }         
          \end{center}
            \caption{Demo Table 2}
            \vspace*{50pt}
        \end{table}

\subsection{Subsection 2}

\cleardoublepage        

\end{document}

enter image description here

  • Thank you so much @egreg! Much appreciated! In the end, I used your suggested code in combination with \renewcommand{\cftbeforefigskip}{} and set the \cftbeforefigskip to a sufficiently negative number till I was happy with the result. It means, that actually even without adding your code, setting a further negative\cftbeforefigskip hack should work similarly .. haven't tested it though! Still, thanks are in order. :) – Amar Oct 1 '16 at 1:21
  • could you please explain what is \p@ from \addtocontents{lof}{\protect\addvspace{10\p@}} and in what situations one may find use of it? Thanks. – Amar Oct 1 '16 at 13:03
  • \p@ means pt, so 10\p@ means 10pt. The LaTeX kernel is full of those ancient artifacts because they save a tiny amount of RAM (which was important in the old days of computing). – user2574 Oct 1 '16 at 16:08
  • 1
    @Amar See What does \p@ mean in some code? – egreg Oct 1 '16 at 16:21

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.