[Tex/LaTex] error confusion when calling hyperref and minitoc package

hyperrefminitoctable of contents

I have a report where I need to use links, when I call the package hyperref I got an error on 18 lines which are correctly compiled when I remove the calling command, the lines are in a chapter in another document which is included at the main one.

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,francais]{babel}
\usepackage[hidelinks]{hyperref} %this line is causing the error
\begin{document}
\include{chapitres/Formats}
\end{document}

the chapter included begin like this

\chapter{Formats de textes et paragraphes}
\minitoc %for mini tableofcontent
\newpage

here is a part of the error code, all the lines are correct when I remove the hyperref package.

enter image description here

Best Answer

The minitoc package requires some more setup than just using \usepackage{minitoc}.

  • \dominitoc to make LaTeX aware that it should generate code for the chapterwise ToC
  • \tableofcontents or \faketableofcontents
  • Without using \section etc. after minitoc will do nothing

More subtle setups require reading the very voluminous manual of minitoc, however.

\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english,francais]{babel}
\usepackage{minitoc}
\usepackage[hidelinks]{hyperref} %this line is causing the error
\dominitoc

\begin{document}
\tableofcontents
\chapter{Formats de textes et paragraphes}
\minitoc %for mini tableofcontent
\section{Foo}
%\include{chapitres/Formats}
\end{document}

The code works with \include{....} as well.

enter image description here