2

Nothing seems to work.

I've tried adding * to \caption. I've tried adding \captionsetup{list=no} to the preamble before the \appendix entry.

I'm using \usepackage{caption}.

Any ideas?

1 Answer 1

5

Ending the .lof file with \endinput

A trick is to end the file .lof via \endinput. Then TeX will not read the lines after \endinput, when the file is \input in the list of figures:

\documentclass{article}

\makeatletter
\g@addto@macro\appendix{%
  \if@filesw % \nofiles is not active
    \immediate\write\@auxout{%
      \string\@writefile{lof}{\string\endinput}%
    }%
  \fi
}%
\makeatother

\begin{document}
  \listoffigures
  \begin{figure}
    \caption{First figure caption}
  \end{figure}
\newpage
\appendix
  \begin{figure}
    \caption{Figure caption not in list of figures}
  \end{figure}
\end{document}

Then the .lof file contains:

\contentsline {figure}{\numberline {1}{\ignorespaces First figure caption}}{1}
\endinput 
\contentsline {figure}{\numberline {2}{\ignorespaces Figure caption not in list of figures}}{2}

And only the first entry is shown.

Disabling \addtocontents for .lof file in \appendix

The following example redefines \addtocontents in \appendix to do nothing, if the contents is meant to go into the list of figures:

\documentclass{article}

\makeatletter
\g@addto@macro\appendix{%
  \newcommand*{\SavedAddToContents}{}%
  \let\SavedAddToContents\addtocontents
  \renewcommand*{\addtocontents}[1]{%
    \def\atc@next{\SavedAddToContents{#1}}%
    \edef\atc@handle{#1}%
    \def\atc@lof{lof}%
    \ifx\atc@lof\atc@handle
      \let\atc@next\@gobble
    \fi
    \atc@next
  }%
}%
\makeatother

\begin{document}
  \listoffigures
  \begin{figure}
    \caption{First figure caption}
  \end{figure}
  \appendix
  \begin{figure}
    \caption{Figure caption not in list of figures}
  \end{figure}
\end{document}

The .lof file contains:

\contentsline {figure}{\numberline {1}{\ignorespaces First figure caption}}{1}

Option list=no of package caption

At least with the simple example file, the option setting list=no works, if added to \appendix:

\documentclass{article}
\usepackage{caption}

\makeatletter
\g@addto@macro\appendix{%
  \captionsetup{list=no}%
}%
\makeatother

\begin{document}
  \listoffigures
  \begin{figure}
    \caption{First figure caption}
  \end{figure}
  \appendix
  \begin{figure}
    \caption{Figure caption not in list of figures}
  \end{figure}
\end{document}

File .lof contains only the first figure caption:

\contentsline {figure}{\numberline {1}{\ignorespaces First figure caption\relax }}{1}

Manual disabling the list entry with package caption

Also the manual method by specifying an empty caption title for the list of figures works here:

\documentclass{article}
\usepackage{caption}

\begin{document}
  \listoffigures
  \begin{figure}
    \caption{First figure caption}
  \end{figure}
  \appendix
  \begin{figure}
    \caption[]{Figure caption not in list of figures}
  \end{figure}
\end{document}
3
  • I would put list=no from caption at the top of the answer, as it is the most simple and convenient way to achieve the result.
    – Johannes_B
    Commented Jun 7, 2015 at 11:17
  • @Johannes_B The OP says, this does not work for him for some unknown reason. Also the first two versions suppress \addvspace commands added by \chapters. Commented Jun 7, 2015 at 11:23
  • 1
    Ah right, but it also says I've tried adding \captionsetup{list=no} to the preamble before the \appendix entry. which is kind of confusing?
    – Johannes_B
    Commented Jun 7, 2015 at 11:25

You must log in to answer this question.

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