0

I faced a problem with the Table Of Content in LaTeX (see the picture)problem with the table of content in LaTeX

The code I'm using:

Preambule:

\usepackage[left=1.5cm,right=1.5cm,top=2.5cm,bottom=1.5cm]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancyplain}
\setlength{\headwidth}{\textwidth}
\setlength{\headsep}{0.5cm}

\pagestyle{fancy}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[french]{babel}
\usepackage{amsmath,amsfonts,amssymb,amsthm,cases}
\usepackage{array,dcolumn,booktabs,multirow,makecell}
\usepackage{enumitem}
\usepackage[dvipsnames,svgnames,table]{xcolor}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{dsfont}

\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{0.2cm}{}

Document:

\tableofcontents
\newpage
\setcounter{page}{1}
\renewcommand{\headrulewidth}{0.5pt}% Remove header rule
\fancyhead[L]{\small{Rapport Projet Maths}}
\fancyhead[C]{Projet Maths}
\fancyhead[R]{\small{ENSISA -- Mulhouse (2021--2022)}}

\section*{Préambule}
\addcontentsline{toc}{section}{Préambule}

\subsection*{Définition des termes utilisés}
\addcontentsline{toc}{subsection}{Définition des termes utilisés}
[...]
\section{choix uniforme de l'un des $K$ traitements}
[...]

Also, I would like to know why there are no dots for section like there are for subsection.

10
  • 3
    First of your should provide a full but minimal exmaple that others can copy and test as is. Secondly, it is probably not a good idea to redefine \thesection like that. Perhaps you should explain what your end goal is here.
    – daleif
    May 17, 2022 at 16:06
  • What is the \no does? Did you define it?
    – Tom
    May 17, 2022 at 16:06
  • @Tom, the \no command is defined in \usepackage[french]{babel} which show May 17, 2022 at 16:14
  • Could you provide a minimal work example? include all the setting in your preamble and some basic content in the document
    – Tom
    May 17, 2022 at 16:19
  • 1
    Not really, we cannot copy this and compile it without adding anything. For example there's no document class
    – daleif
    May 17, 2022 at 16:55

1 Answer 1

1

Use the tocloft package.

\documentclass...
\usepackage{tocloft}

Provide more space for the section number:

\renewcommand{\cftsecnumwidth}{4em} % change 4em to suit

Dotted leader for sections:

\renewcommand{\cftsecdotsep}{\cftdotsep}

Read the manual for more information.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .