2

I want my main TOC to only show chapters. Not sections and subsections. This is report class. So I added \setcounter{tocdepth}{0} which worked. But then I noticed something strange. minilof and minilot in my chapters are now all empty. But minitoc is not empty.

How can one make the main TOC shows only chapters, but still have a minilot and minilof in each chapter? Here is a MWE

\documentclass[12pt]{report}%   
\usepackage{minitoc}  
\begin{document}
\dominitoc  %initialize
\dominilof
\dominilot
\setcounter{tocdepth}{0} %For the main TOC, only show chapter, but this
     %makes minilot not to show up ! change to 1 to have minilot show up!
\tableofcontents
\listoffigures
\listoftables        
ok....    
\chapter{chapter test}
\minitoc  %this show OK
\minilof  %this is empty
\minilot

here we go, one table, to see if it will show up in minilot

\begin{table}[!htbp]
\centering
\caption{my table}
\begin{tabular}{|c|}\hline
nice table\\\hline
\end{tabular}
\end{table}
\section{section below the chapter}
some section
\end{document}

Compiling with pdflatex, shows this:

Mathematica graphics

changing \setcounter{tocdepth}{0} to \setcounter{tocdepth}{1} now it shows:

Mathematica graphics

question is: How to make main TOC only show chapters, but still be able to use minilot and minilof. Notice that there is no issue with minitoc.

Using TL 2015

 *File List*
  report.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
 minitoc.sty    2015/07/13 v61 Package minitoc
 mtcmess.sty    2006/03/14
     foo.mtc0
 english.mld    2006/01/13
 english.mld    2006/01/13
4

Is this what is meant? Writing \setcounter{tocdepth}{0} to the .toc file and restoring this afterwards by using some default level (say 3) in the .lof and .lot -- this assumes, that \listoffigures or \listoftables is used after \tableofcontents

\documentclass[12pt]{report}%   
\usepackage{minitoc}  
\def\mytocdepth{3}
\begin{document}
\dominitoc  %initialize
\dominilof
\dominilot
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\addtocontents{lot}{\protect\setcounter{tocdepth}{\mytocdepth}}
\addtocontents{lof}{\protect\setcounter{tocdepth}{\mytocdepth}}
%\setcounter{minitocdepth}{\mytocdepth} %For the main TOC, only show chapter, but this
     %makes minilot not to show up ! change to 1 to have minilot show up!
\tableofcontents
\listoffigures
\listoftables        
ok....    
\chapter{chapter test}
\minitoc  %this show OK
\minilof  %this is empty
\minilot

here we go, one table, to see if it will show up in minilot

\begin{table}[!htbp]
\centering
\caption{my table}
\begin{tabular}{|c|}\hline
nice table\\\hline
\end{tabular}
\end{table}

\begin{figure}[!htbp]
\centering
\caption{my figure}
\end{figure}

\section{section below the chapter}
some section
\end{document}
  • Thanks, that works on MWE, but there is a HUGE problem. I found it fails when I include, guess what, the \usepackage{breqn} then I get many errors!. Undefined control sequence. \addtocontents{toc}{\setcounter{tocdepth}{0}} etc.. many syntax errors are generated when just adding the above package, which I have to have there. Very strange. If you know a workaround or why that happens. Or I could post separate question if needed. But as it stands, I can't use this solution at this moment because of this. Thanks. – Nasser May 10 '16 at 9:54
  • @Nasser: That's due to the fact that \setcounter is fragile. Use \protect\setcounter{...}{...} for the toc-writing, see my update please. – user31729 May 10 '16 at 9:57

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.