1

While writing my thesis I found that subfigures in chapters that are added via \input are displayed with wrong pagenumbers in the list of figures. I've included a MWE.

Some important notes might be:

  1. Normal figures are displayed correctly
  2. I'm using the subcaption package
  3. I've encountered a similar problem with glossaries entries (not included in this MWE for simplicity)

\documentclass{book}

\usepackage[utf8]{inputenc}%    characters 
\usepackage[T1]{fontenc} 
\usepackage[demo]{graphicx}
\usepackage[list=true,listformat=simple]{subcaption}

\begin{document}

\input{mwe_chap1} % The input file

\chapter{Two}\label{ch:two} % Example that does work without \input

\begin{figure}[hbtp]
\begin{subfigure}[t]{0.32\textwidth}    \includegraphics[height=3cm]{x}
    \caption{4\label{fig:d}}    \end{subfigure} %
    \begin{subfigure}[t]{0.32\textwidth}    \includegraphics[height=3cm]{x}
    \caption{5\label{fig:e}}    \end{subfigure} %
    \begin{subfigure}[t]{0.32\textwidth}    \includegraphics[height=3cm]{x}
    \caption{6\label{fig:f}}    \end{subfigure} \end{figure}

\chapter{Three}\label{ch:three}

\listoffigures % Prints the list of figures

\end{document}

Here is the input file:

\chapter{One}\label{ch:one}
some text \clearpage
\begin{figure}[hbtp]    \begin{subfigure}[t]{0.32\textwidth}
    \includegraphics[height=3cm]{x}     \caption{1\label{fig:a}}
\end{subfigure} %   


\begin{subfigure}[t]{0.32\textwidth}
        \includegraphics[height=3cm]{x}     \caption{2\label{fig:b}}
        \end{subfigure} %   
    \begin{subfigure}[t]{0.32\textwidth}
        \includegraphics[height=3cm]{x}     \caption{3\label{fig:c}}
        \end{subfigure} \end{figure}
\clearpage some text

\clearpage some text

\begin{figure}[hbtp] \includegraphics[height=3cm]{x}  \caption{normalfig\label{fig:normal}} 
\end{figure}

Any help would be greatly appreciated!

EDIT:

The problem seems to dissappear when I add a caption to the \figure environment in the external chapter, like such:

\begin{figure}[hbtp]
    \begin{subfigure}[t]{0.32\textwidth}
        \includegraphics[height=3cm]{x}     \caption{1\label{fig:a}}
        \end{subfigure} %   
    \begin{subfigure}[t]{0.32\textwidth}
        \includegraphics[height=3cm]{x}     \caption{2\label{fig:b}}
        \end{subfigure} %   
    \begin{subfigure}[t]{0.32\textwidth}
        \includegraphics[height=3cm]{x}     \caption{3\label{fig:c}}
        \end{subfigure}
\caption{added caption\label{fig:extracap}} % This caption is added
\end{figure}

It seems that the counter counts differently with the extra caption... I don't see how. However, is there no way to just list the subfigures without an extra caption for the total figure environment?

3
  • Please don't use the Block Quote mode for code, this causes more problems than necessary ;-)
    – user31729
    Aug 3, 2016 at 20:30
  • ah which should i use? thx for the edit :)
    – Aad
    Aug 3, 2016 at 20:35
  • Mark the code and press CTRL-K or click on the {} symbol in the editor instead!
    – user31729
    Aug 3, 2016 at 20:36

2 Answers 2

0

This is a possible solution to have correct page numbering in the LoF for the subfigures without adding a caption in the main text to the figure environment:

  1. Declare a blank caption format
  2. Add a caption to the \figure with the above mentioned caption setup

}

\usepackage{caption}
\DeclareCaptionLabelFormat{blank}{}

\begin{figure}[hbtp]
    \begin{subfigure}[t]{0.32\textwidth}
      \includegraphics[height=3cm]{x} 
      \caption{1\label{fig:a}}
      \end{subfigure}
    \begin{subfigure}[t]{0.32\textwidth}
      \includegraphics[height=3cm]{x} 
      \caption{2\label{fig:b}}
      \end{subfigure}
    \begin{subfigure}[t]{0.32\textwidth}
      \includegraphics[height=3cm]{x} 
      \caption{3\label{fig:c}}
      \end{subfigure}
\captionsetup{textformat=empty,labelformat=blank}
\caption{ACaptionThatDoesNotShowInMainText\label{fig:hiddencap}}    
\end{figure}
0

Add a \phantomcaption to the figures which contains sub-captions but no main caption. (Unfortunately this one is not documented yet since the documentation is lagging behind.)

Addendum:

I just opened a ticket so this will be documented ASAP: https://sourceforge.net/p/latex-caption/tickets/48/

You must log in to answer this question.

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