# Problem pagestyle for toc and minitoc for thesis

I have a problem with my document. I looked on Google but did not find the solution. I just want to homogeneize my page style in my whole document but it does not work for my table of content and my minitoc pages.

Furthermore, I would like to have a page numbering on the right for impair pages and on the left for pair pages. I tried using RO but it did not work. I have also already tried the "twoside" in the definition of my document class but it did not work either !

Please find here my document :

\documentclass[12pt,a4paper]{report}

%définition des packages
\usepackage{anyfontsize}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\usepackage[french]{babel}
\usepackage[margin=1in, headsep=5pt]{geometry}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage[pdftex]{graphicx}
\usepackage{hyperref}
\usepackage{url}
\usepackage{caption}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[Sonny]{fncychap}
\usepackage[tight]{minitoc}
\mtcselectlanguage{french}
\usepackage{titlesec}
\usepackage{titletoc}

\pagestyle{empty}
\fancyhf{}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt}
\setlength{\footskip}{20pt}
\fancyfoot[C]{}
\fancyfoot[RO]{\thepage}

\begin{document}
\newpage
\dominitoc
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{1}
\setcounter{minitocdepth}{3}
\renewcommand{\contentsname}{\hfill \fontsize{20}{30}{\fontfamily{rm}\selectfont{Table des matières}}}

\pagenumbering{roman}
\tableofcontents

\renewcommand{\chaptername}{\hfill \fontsize{20}{30}{\fontfamily{rm}\selectfont{Chapitre}}}

\chapter{\fontfamily{rm}\selectfont{Chapitre bibliographique}}
\pagenumbering{arabic}
\minitoc
\newpage
%style de page
\pagestyle{empty}
\fancyhf{}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\headrulewidth}{1pt}
\setlength{\footskip}{20pt}
\setlength{\headheight}{50pt}
\fancyhead[L]{\textsc{\fontsize{15}{15}\selectfont{Chapitre 1. Chapitre bibliographique}}}
\fancyfoot[C]{}
\fancyfoot[RO]{\thepage}
\titlespacing{\section}{1pt}{0.5pt}{0.5pt}

{\titleformat*{\section}{\fontsize{15}{15}\bfseries\fontfamily{cmss}\selectfont}
\section{Projection cold spray}}
\hrule height 1pt
\vspace{5mm}
\end{document}


Thanks a lot in advance for your help :)

• Please complete the posted MWE. It should end with \end{document}. Make sure that when compile it in your system produces the unwanted results you mentioned. Mar 23, 2021 at 12:40
• I editted my post. It was already there in my personal document, I just forgot to add it there ! The problem is thus still there :) Mar 23, 2021 at 12:55
• Update the package fancyhdr. Mar 30, 2021 at 17:36

## 1 Answer

I prepared a document with two chapters and several three sections in seven pages to see the TOC, the miniTOC and the headers of several pages.

Generally two page styles are defined: plain and fancy.

With standard classes, each \chapter invokes the plain style. The fancy style applies to normal pages. To toggle the position of page numbers, on odd and even pages, use the twoside option.

I simplified the code for you. New commands and redefinitions generally belong to the preamble if their scope is the entire document. Otherwise one is easily confused.

This is the code.

% !TeX TS-program = pdflatex

\documentclass[12pt,a4paper,twoside]{report} %
%to toggle the position of page numbers, on odd and even pages, use the   twoside option.

%définition des packages
\usepackage{anyfontsize}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{helvet}
\usepackage[french]{babel}
\usepackage[top=1.5cm, bottom=1.5cm, left=2.5cm, right=1.5cm, headheight=1cm, headsep=2mm]{geometry} %<<< changed

\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{fancyhdr}
\usepackage{graphicx} %changed <<<<
\usepackage{url}
\usepackage{caption}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage[Sonny]{fncychap}
\usepackage[tight]{minitoc}
\mtcselectlanguage{french}
\usepackage{titlesec}
\usepackage{titletoc}

%\usepackage{hyperref}  % MUST BE LAST PACKAGE commented to avoid link red boxes in TOC for this MWE

\fancypagestyle{plain}{% first page of chapters
\fancyhf{}
\fancyhead[L]{}
\fancyfoot[R]{\thepage}
%\fancyfoot[C]{\thepage} % usual alternative
\renewcommand{\headrulewidth}{0pt}
}

\fancypagestyle{fancy}{% normal pages
\fancyhf{}
\fancyhead[L]{\leftmark}
\fancyfoot[RO]{\thepage}
\fancyfoot[LE]{\thepage}
}

\pagestyle{fancy}
\renewcommand{\footrulewidth}{1pt} %equal foot and head rule
\renewcommand{\headrulewidth}{1pt}
\setlength{\footskip}{25pt} % this is quite small it should be 40pt or more and
% bottom = 2.5cmm in geometry

\renewcommand{\contentsname}{\hfill \fontsize{20}{30}{\fontfamily{rm}\selectfont{Table des matières}}}
\renewcommand{\chaptername}{\hfill \fontsize{20}{30}{\fontfamily{rm}\selectfont{Chapitre}}}

\titlespacing{\section}{0pt}{5pt plus 2pt minus 1pt}{0pt plus 2pt minus 1pt}
\titleformat{\section}
{\fontfamily{cmss}\fontsize{15}{18}\selectfont\bfseries}{\thesection}{1em}{}[{\titlerule[1pt]\vskip 1ex}]

\usepackage{kantlipsum} % dummy text, (english sorry)

\begin{document}
\newpage
\dominitoc
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{1}
\setcounter{minitocdepth}{3}

\pagenumbering{roman}
\tableofcontents

\chapter{Préliminaire}

\pagenumbering{arabic}
\minitoc

1. \kant[1-5]
\section{Projection cold spray}

2. \kant[11-15]

\section{Projection hot spray}

3. \kant[19-22]

\section{Without spray}

4. \kant[11-12]

\chapter{Chapitre bibliographique}
\minitoc

\section{Sources primaires}
9. \kant[9]
\section{Sources secondaires}
10. \kant[10-15]
\end{document}

• Thank you so much for this, I can't believe that you did all this. It seems perfect ! Of course I tried right away to compile it (I use TeXMaker) but it did not work. The process of compilation start and never end it is so frustrating ! Do you have any clue why it does not work (my computer is making so much noise it seems that try hard to male it work). Again, thank you so much for your help everything is very clear ! Mar 24, 2021 at 11:17
• Noise is bad news: faulty fan-> higher temperatures_> processor might fail; disk drive failing or bad sectors. Mar 24, 2021 at 12:34
• But it really appears when I launch the compilation of the new code ! There is no reason for that, the document is not that big... Is there a line which could implicate this bug in your opinion ? Mar 24, 2021 at 12:49
• Nothing I can think of. It stops after a while or never ends? (1) Try a different code you might have (2) Comment most of the packages. You only need fancyhdr, minitoc and titlesec to run this MWE Mar 24, 2021 at 12:58