# Are minitoc and tableof packages compatible?

Edit: Okay, I worked longer on my issue. I isolated the issue and produced a very minimal code to reproduce the issue.

The following code does not produce what I wish.

• Each chapter should contain a minitoc at the beginning.
• Each section should start by tags which are linked to other section through hyperref and should end by a table of section containing a main tag of the section. For instance, if the sec1 define the tag 'a', then all sections referring to the tag 'a' should appear in this last table.

I produced a latex document able to do this. However, \tableof and \minitoc does not work long after the first call.

So there is an example what I want on the left, and what I have on the right :

And here is the new code :

\documentclass[]{book}

\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{tableof}
\usepackage{hyperref}
\usepackage{import}
\usepackage{minitoc}

%1 : title
%2 : tags reference
%3 : tags

%tag the content
\toftagthis{#3}
\section[#1]{ \hypertarget{#2}{#1} }
%for visual content
\keywords{#3}
}

\newcommand{\sectionFoot}[1]{
% Keyword of the section
\subsection[Table of tags]{Table of tags}
\tableof{#1}
\newpage
}

\newcommand{\keywords}[1]{%
\def\nextitem{\def\nextitem{, }}
\textbf{tags:} \docsvlist{ #1 }
}

\begin{document}

\dominitoc
\tableofcontents

\chapter{Ch 1}
\minitoc

\lipsum[1]

\sectionFoot{a}

\lipsum[1]

\sectionFoot{b}

\lipsum[1]

\sectionFoot{c}

\chapter{Ch 2}
\minitoc

\lipsum[1]

\sectionFoot{d}

\lipsum[1]

\sectionFoot{e}

\lipsum[1]

\sectionFoot{f}

\end{document}


Do you know how I should proceed to solve this ?

Edit: I tried the command

\setcounter{mtc}{*number of the chapter*}


without success.

• \tableofcontents is defined by the common latex classes. What are you actually trying to do? What's your question? – Teepeemm Mar 11 '17 at 20:46
• @ThomasAuriel: Welcome to TeX.SE. You should really provide a compilable example – user31729 Mar 11 '17 at 21:25
• I made a minimal example. I manage to remove import and input function since they are not causing my issue. – ThomasAu Mar 13 '17 at 16:30
• It seems to be a problem of tableof with \newpage after \tableof command. I don't know why? – touhami Mar 14 '17 at 14:48
• @touhami Add Hello right before \end{document}. Else there is an \AtEndDocument command issued by tableof which remains without effet. The main toc file is lacking a \tof@finish at its very end. – user4686 Mar 14 '17 at 15:47

Version 1.4b of tableof has been released to fix the root cause of this problem. (sorry for delay...)
There is a priori no incompatibility of tableof vs minitoc. The issue in your document comes from the fact that the last thing before \end{document} is a \newpage (as pointed out by @touhami). This means that \end{document} gets executed at a time the last page is already shipped out. This causes the loss of some instruction put by tableof in an \AtEndDocument command. As a result a macro is missing from the main toc file and you get the missing TOCs syndrom. The simplest is for the time being to avoid ending your document body with \newpage as the last thing. If this is unavoidable, then a not completely general workaround has been pointed out in comments.