1

I really need your help on some following problems. Any help is highly appreciated. Many thanks to you in advanced.

  1. I created a report with Part, Chapter, Section,.... But there are some Titles, I want to include them into the Table of contents (Like Introduction, Annex,...) with the format as same as the Part (Font, color, dots connecting with the page number). Could you please show me how to do that?

  2. I created also the header / footer. For some pages, I inserted the code. \thispagestyle{fancy} to force the page with the form of header/footer as defined in the code. It works for the page of Tables of contents, Chapter,... But for the page of Part, it doesn't. So how to apply the form header/footer for this page?

enter image description here

  1. There is some big marge (gap) between the header and the Content, the Chapter. How to reduce this gap as we want?

You can see the photos attached and the code.

Thank you to much.

enter image description here

\documentclass{report}

%%%%% Format font + page + langue
\usepackage[utf8x]{inputenc}
\usepackage[a4paper,top=2.5cm,bottom=2cm,left=2.5cm,right=2cm,marginparwidth=1.75cm,headheight=35pt]{geometry}

\usepackage[english]{babel}

\usepackage[T1]{fontenc}
\setlength{\parindent}{0cm}
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{1}
\usepackage[titletoc]{appendix}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

%%%%% Indentfirst
\usepackage{indentfirst}
\setlength{\parindent}{1cm}
\usepackage{libertine} 
\usepackage{lmodern}

%%%%% Header + Footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lfoot{Minh Tu \textsc{Pham} \copyright}
\cfoot{Rapport de stage}
\rfoot{\textbf{Page \thepage}}

\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}

%%%%% Create image + photo
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
%\usepackage[colorlinks=true, allcolors=blue]{hyperref}
\usepackage{amsmath,amssymb,amsthm,amsfonts,mathrsfs}
\usepackage{float}
\usepackage[export]{adjustbox} %% choose the position (left, right) of a image
\usepackage{subcaption} %% pour put many images in 1 figure
\usepackage{wrapfig} %% wrap text and image
\usepackage{babelbib}
\usepackage{caption}

%%%%% Table of contents
\setcounter{secnumdepth}{5} % seting level of numbering in the document
\setcounter{tocdepth}{5} % seting level of numbering in the ToC
\usepackage[colorlinks=true]{hyperref}
\usepackage{tocloft}
\newcommand{\Color}[1]{\hypersetup{linkcolor=#1}\color{#1}}
\renewcommand{\cftpartfont}{\Color{red}\large\bfseries}
\renewcommand{\cftchapfont}{\Color{red}\large\bfseries}
\renewcommand{\cftsecfont}{\Color{blue}}
\renewcommand{\cftsubsecfont}{\Color{green}}
\renewcommand{\cftsubsubsecfont}{\Color{black}}
\renewcommand{\cftpartpagefont}{\large\bfseries\Color{red}}
\renewcommand{\cftchappagefont}{\large\bfseries\Color{red}}
\renewcommand{\cftsecpagefont}{\Color{blue}}
\renewcommand{\cftsubsecpagefont}{\Color{green}}
\renewcommand{\cftsubsubsecpagefont}{\Color{black}}
\renewcommand{\cftpartleader}{\large\bfseries\color{red}\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapleader}{\large\bfseries\color{red}\cftdotfill{\cftdotsep}}
\renewcommand{\cftsecleader}{\Color{blue}\cftdotfill{\cftsecdotsep}}
\renewcommand{\cftsubsecleader}{\Color{green}\cftdotfill{\cftsubsecdotsep}}
\renewcommand{\cftsubsubsecleader}{\Color{black}\cftdotfill{\cftsubsubsecdotsep}}


\begin{document}
\tableofcontents \thispagestyle{fancy}
\newpage
\begin{center}
\huge\bfseries{Remerciements}
\end{center}

benefits



\newpage
\begin{center}
\huge\bfseries{Introduction}
\end{center}

tion benefits

\newpage
\part{Aba asg asdf asdf asdf } \thispagestyle{fancy}

\chapter{AS asdfa sdfasdj h ert bc bcvb} \thispagestyle{fancy}

\section{adfas}
\section{asfasf asfd a}

\chapter{B asfd as asd fasdf asdf asdf}
\section{asdfasdf asdfasdfa}
\subsection{asdf asdfa sdfasdfa}


\newpage
\begin{center}
\huge\bfseries{References}
\end{center}
asdf a
benefits


\end{document}
  • (1) \part*{Anexx}\addcontentsline{toc}{part}{Anexx} should solve. – Sigur Dec 1 '18 at 20:25
  • @Sigur Thank you friend Sigur. I did as you recommend but It breaks the title in to a new page only. I want it could show as the titles "Remerciements", "Introduction",.... on the top of page, and with the font as in the code. Then, the contents are right below. Could you help me? – Dg PHAM Dec 1 '18 at 20:40
  • You have to decide if you want to format it like \part{} or like \chapter{}. The * removes the number, so you need to add that command to toc, choosing part or chapter depending whic one you used. – Sigur Dec 2 '18 at 15:14
1

These are three different questions. Here I will answer only the second question.¹

To get the same header and footer on plain pages (like chapter or part pages) use fancyplain instead fancy and redefine \plainheadrulewidth and \plainfootrulewidth.

Example:

\documentclass{report}
\usepackage{lipsum}% only for dummy text

\usepackage{fancyhdr}
\pagestyle{fancyplain}% <- changed
\fancyhf{}
\lfoot{Minh Tu \textsc{Pham} \copyright}
\cfoot{Rapport de stage}
\rfoot{\textbf{Page \thepage}}

\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\plainheadrulewidth}{0.5pt}% <- added
\renewcommand{\plainfootrulewidth}{0.5pt}% <- added

\begin{document}
\tableofcontents
\part{A part}
\chapter{A chapter}
\lipsum
\part{A second part}
\chapter{A second chapter}
\lipsum
\end{document}

Result:

enter image description here

¹ Please ask new questions for the other problems and provide there short examples showing a single issue.

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.