# ToC formatting - numbers too close to section headers [duplicate]

I am putting together a report as part of a group project for part of physics degree, and I have been having fun trying to format the table of contents correctly. Here is a MWE:

    \documentclass[twoside]{article}
\usepackage[a4paper,pdftex,left=1.7cm,right=1.7cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage{blindtext}
\usepackage[english]{babel}
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}

\begin{document}
\tableofcontents
\newpage

\begin{abstract}
\blindtext
\end{abstract}

\section{A section}
\blindtext
\section{Another section}
\blindtext
\subsection{A subsection}
\blindtext
\subsection{Yet another subsection}
\blindtext
\subsubsection{Oh, exciting, a sub sub section!}
\blindtext
\section{Another boring old section}
\blindtext

\end{document}


Which gives something like this as the output:

Not bad, except for the spacing between the sections and their respective numbers is far too small. I tried to fix it by including this in the preamble:

    \makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{3em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{3.0em}{3.5em}}
\renewcommand{\l@subsubsection}{\@dottedtocline{3}{4.5em}{4.2em}}
\makeatother


giving this:

Although it allows me to adjust the spacing to my liking (not adjusted correctly in the picture, just an example), I seem to have lost the bold font and gained some dots for my sections which were previously absent. I have also lost the nice spacing between sections. I tried getting the bold font back with

    \renewcommand\cftsecfont{\bfseries}


but it didn't seem to have any effect. Any advice on how to better format my ToC would be appreciated. I don't have to comply with any specific layout of formatting specified by the university, but I do want it to look clear and professional. The first example was perfect except for the section numbers being stuck right next to the sections, although it was fine for the subsections.

## marked as duplicate by karlkoeller, Svend Tveskæg, user13907, Werner, Gonzalo Medina table-of-contents StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Feb 16 '15 at 18:40

• Welcome to TeX.SX! Why  \renewcommand*\thesection{\arabic{section}.0}? – user31729 Feb 16 '15 at 12:38
• Thanks for the welcome - see my response to Christian Hupfer for the reasoning behind the additional '0.1'. Although removing that temporarily fixes it, the spacing still becomes an issue with the number of sections enters double digits. – George Feb 16 '15 at 14:15

The width used for the section numbers in a Toc (article class) can be set by readjusting

\cftsecnumwidth to an appropiate value (30ptin my example).

The package tocloft is needed for this.

I don't understand the purpose of

\renewcommand*\thesection{\arabic{section}.0} however.

 \documentclass[twoside]{article}
\usepackage[a4paper,pdftex,left=1.7cm,right=1.7cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage{blindtext}
\usepackage[english]{babel}
\usepackage{tocloft}
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}

\renewcommand{\cftsecnumwidth}{30pt}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{4}

\begin{document}
\tableofcontents
\newpage

\begin{abstract}
\blindtext
\end{abstract}

\section{A section}
\blindtext
\section{Another section}
\blindtext
\subsection{A subsection}
\blindtext
\subsection{Yet another subsection}
\blindtext
\subsubsection{Oh, exciting, a sub sub section!}
\blindtext
\section{Another boring old section}
\blindtext

\end{document}


• This is definitely a duplicate ;-) – Johannes_B Feb 16 '15 at 13:25
• @Johannes_B: Yes, most likely – user31729 Feb 16 '15 at 13:25
• Brilliant, thank you. I am sorry if this is a duplicate, but none of the previous answers I could find seemed to work in the article class or without using tocloft or similar. The extra '.0' for sections was how the lab demonstrator told me to format my lab reports last year, however this came from the same demonstrator who told me sunlight took around 50 seconds to reach the earth and that magnetic perpetual motion machines were theoretically possible, so I am quite willing to accept that his notions of report formatting were also incorrect... Thanks again for the help. – George Feb 16 '15 at 14:11
• @George: The manual of tocloft reveals a lot of deals (although a little bit hard to read ;-)) The .0 is indeed... eh, weird ;-) – user31729 Feb 16 '15 at 14:14