# how to show list of figures and list of tables inside chapters only and not also at top of document?

This is a follow up question from setting-tocdepth-to-zero-in-report-class-makes-minilot-and-minilof-not-show-up but I have new problem now and it is really a new question but related.

I have a main document that reads number of chapters from different locations. I am using minitoc to show a toc in each chapter, and also show list of figures and list of table in each chapter.

But I do not want to also duplicate this and show the list of figures and list of tables in the main TOC for the document, since it will clutter the main TOC.

If I need to see list of figures for a chapter, I can always go to the chapter to see them, since each chapter is independent from the other, this seems to make more sense.

But to be able to show LOF and LOT in each chapter I am forced to issue the commands \listoffigures and \listoftables in the main document so that minitoc can read the lists.

Is there a way to compile the list of figures and tables, to make minitoc do its job, but not show them at the main toc?

MWE (showing just case for tables, but the same for figures also)

\documentclass[11pt]{report}%
\usepackage{graphicx}
\usepackage{minitoc}
%see https://tex.stackexchange.com/questions/308838/setting-tocdepth-to-zero-in-report-class-makes-minilot-and-minilof-not-show-up
\def\mytocdepth{3}
\begin{document}
\dominitoc
\dominilof
\dominilot
%For the main TOC, only show chapter,section
%now what to do where lot and lof? if make these 0 also,
%then nothing shows up. If I do not change it, lot shows up here
%which I do not want.
\tableofcontents
\listoffigures
\listoftables  %have to do this, else can't show minilot in chapter
%but I do not want to show list of table here, only in chapter

\chapter{A}
\minitoc
\minilof
\minilot
\begin{table}
\caption{my table}
\end{table}
etc....
\begin{figure}
\caption{my figure}
\end{figure}

\end{document}


I tried

\addtocontents{lot}{\protect\setcounter{tocdepth}{0}}


Above, but that did not work.

Question is: How to show lof and lot in chapters only but not in main TOC?

The \tableofcontents or \listof... macros use \@starttoc{X} where X is the extension of the relevant ToC file, i.e. toc or lot.

However, \@starttoc uses an \@input to read the content of the relevant file and typesets this list of ... then.

This could either be patched out or using a 'copy' of the \@starttoc command which is used in \listoftables and \listoffigures then (after a redefinition).

Since the List of -- heading is most likely not wanted, I used a very primitive definition of \listoftables here.

\documentclass[11pt]{report}%

\newif\ifshowlistof

\makeatletter

\def\@starttocbutdonotshowtoc#1{%
\begingroup
\makeatletter
\setcounter{tocdepth}{\mytocdepth}
\ifshowlistof
\@input{\jobname.#1}%
\fi
\if@filesw
\expandafter\newwrite\csname tf@#1\endcsname
\immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
\fi
\@nobreakfalse
\endgroup}

\renewcommand{\listoftables}{%
\@starttocbutdonotshowtoc{lot}%
}

\renewcommand{\listoffigures}{%
\@starttocbutdonotshowtoc{lof}%
}

\makeatother

\usepackage{minitoc}
%see http://tex.stackexchange.com/questions/308838/setting-tocdepth-to-zero-in-report-class-makes-minilot-and-minilof-not-show-up
\def\mytocdepth{3}
\begin{document}
\dominitoc
\dominilof
\dominilot

\tableofcontents
\listoffigures
\listoftables  %have to do this, else can't show minilot in chapter
%but I do not want to show list of table here, only in chapter

\chapter{A}
\minitoc
\minilof
\minilot
\begin{table}
\caption{my table}
\end{table}

\begin{figure}
\caption{A figure}
\end{figure}
etc....
\end{document}


• \fakelistoftables does not work here
– user31729
May 12 '16 at 12:01
• Thanks. I have been having hard time getting your code changed to make it also do the list of figures. Do I need new command or should I duplicate the whole thing starting from makeatletter? Could you please show how to also add the list of figures? I've updated my MWE to also add a figure as an example. I am a newbie in Latex. May 12 '16 at 12:08
• @Nasser: Well, it's straightforward ;-)
– user31729
May 12 '16 at 12:09
• Well, I tried the direct method. I did \renewcommand{\listoffigures}{% \@starttocbutdonotshowtoc{lof}% }  but it did not work May 12 '16 at 12:10
• @Nasser: See the update please
– user31729
May 12 '16 at 12:51