[Tex/LaTex] Remove appendix tables and figures from list of figure/tables

table of contents

I'm writing a thesis and I have over hundred figures and tables in the appendix. But I don't want them to appear in List of figures / List of tables. – But I want the appendices and sections to appear in the table of content.

\documentclass[a4paper,12pt,icelandic]{report}
\usepackage[toc,page]{appendix}


\begin{document}
\tableofcontents

\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}

\listoftables
\addcontentsline{toc}{chapter}{List of tables}

\chapter{Chapter 1}
\section{Section 1, chapter 1}
\section{Section 2, chapter 1}

\appendix
\addcontentsline{toc}{chapter}{Appendices}
\chapter{First appendix}
\section{Section 1}
    \begin{figure} % DON'T WANT THIS TO APPEAR IN LIST OF FIGURES
    \centering
    \includegraphics[width=1\linewidth]{figure.png}
    \caption{Caption of figure}
    \label{Label of figure}
    \end{figure}

\begin{table}   % DON'T WANT THIS TO APPEAR IN LIST OF TABLES
    \begin{tabular}{|c|c|}
        \hline One & Two \\ 
        \hline Three & Four \\ 
        \hline 
    \end{tabular} 
    \caption{Caption of table}
    \label{Label of table}
\end{table}


\end{document}

Best Answer

Right before the appendix, I redefine \addcontentsline to intercept {figure} and {table} calls and excise them, as follows (requires ifthen package):

\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
  \ifthenelse{\equal{#1}{lof}}{}%
  {\ifthenelse{\equal{#1}{lot}}{}{\svaddcontentsline{#1}{#2}{#3}}}}

Here is my MWE (note: I added a body figure and table to demonstrate ability to discern report body from appendix)

\documentclass[a4paper,12pt,icelandic]{report}
\usepackage[toc,page]{appendix}
\usepackage{graphicx,ifthen}

\begin{document}
\tableofcontents

\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}

\listoftables
\addcontentsline{toc}{chapter}{List of tables}

\chapter{Chapter 1}
\section{Section 1, chapter 1}

    \begin{figure} % DO WANT THIS TO APPEAR IN LIST OF FIGURES
    \centering
    \includegraphics[width=1\linewidth]{example-image}
    \caption{Body figure}
    \end{figure}
\begin{table}   % DO WANT THIS TO APPEAR IN LIST OF TABLES
    \begin{tabular}{|c|c|}
        \hline One & Two \\ 
        \hline Three & Four \\ 
        \hline 
    \end{tabular} 
    \caption{Body table}
\end{table}

\section{Section 2, chapter 1}

\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
  \ifthenelse{\equal{#1}{lof}}{}%
  {\ifthenelse{\equal{#1}{lot}}{}{\svaddcontentsline{#1}{#2}{#3}}}}

\appendix
\addcontentsline{toc}{chapter}{Appendices}
\chapter{First appendix}
\section{Section 1}
    \begin{figure} % DON'T WANT THIS TO APPEAR IN LIST OF FIGURES
    \centering
    \includegraphics[width=1\linewidth]{example-image}
    \caption{Caption of figure}
    \label{Label of figure}
    \end{figure}
\begin{table}   % DON'T WANT THIS TO APPEAR IN LIST OF TABLES
    \begin{tabular}{|c|c|}
        \hline One & Two \\ 
        \hline Three & Four \\ 
        \hline 
    \end{tabular} 
    \caption{Caption of table}
    \label{Label of table}
\end{table}

\end{document}

enter image description here

enter image description here

ADDENDUM

A version of the redefinition that does not require the ifthen package:

\let\svaddcontentsline\addcontentsline
\renewcommand\addcontentsline[3]{%
  \edef\qtest{#1}%
  \def\qmatch{lof}%
  \ifx\qmatch\qtest\else%
    \def\qmatch{lot}%
    \ifx\qmatch\qtest\else%
      \svaddcontentsline{#1}{#2}{#3}%
  \fi\fi%
}