# Different spacing between section number and its caption TOC

I want to use two different spacing between section number and its caption in the Table of Contents (TOC)

I already have tried the solutions:

TOC Text - numbers alignment

But I think they are not suitable.

Well the minimal example is:

\documentclass[a4paper,12pt,twoside]{scrreprt}

\usepackage{hyperref}

\usepackage{tocloft}

%%% Configure de distance
\setlength{\cftsecnumwidth}{4em}

\begin{document}
\tableofcontents

\chapter{Hardware Data} \label{chap.hardware}

\setcounter{section}{19}

\section{Test section one}
\subsection{test section one one}
\subsection{test section one two}

\section{Test section two}
\subsection{test section two one}
\subsection{test section two two}

%%%% Appendix
\cleardoublepage
\phantomsection
\appendix
\chapter*{Appendix}

\chapter{Appendix Test Chapter}

\setcounter{section}{199}
\section{Test Section}

%%%%%%%%%%%%%%%% Annex:
\cleardoublepage
\phantomsection
\setcounter{chapter}{0}
\renewcommand{\theHchapter}{an.\Alph{chapter}}
\renewcommand{\thechapter}{$\,\!$\Alph{chapter}}

\renewcommand{\appendixname}{Annex}
\chapter*{Annex}

\renewcommand{\thesection}{\thechapter$_{x}$.\arabic{section}}

\chapter{Annex Test Chapter}

\setcounter{section}{1199}
\section{Test Section}

\end{document}


Wich results in the figure below, depending on

\setlength{\cftsecnumwidth}{4em}


Well, in the Annex I want more space, but I also want to keep the smaller spacing for the sections in the regular chapters.

Does anyone have a clue and/or can help ?

Thanks a lot !

Will

PS: For the record, I have also asked this question in

http://latex-community.org/forum/viewtopic.php?f=47&t=23471

The process might be somewhat counter-intuitive, but you need to insert the spacing changes mid-document for it to have a partial effect in the ToC. The reason for this is because the entire .toc file is read during a call to \tableofcontents. Therefore, changing anything prior to that (in the preamble, for example), will have an effect for the entire ToC. The solution is to add

\addtocontents{toc}{\setlength{\cftsecnumwidth}{4em}}


just after you initiate the Appendix:

\documentclass[a4paper,12pt,twoside]{scrreprt}% http://ctan.org/pkg/koma-script

\usepackage{hyperref}% http://ctan.org/pkg/hyperref

\usepackage{tocloft}

\begin{document}
\tableofcontents

\chapter{Hardware Data} \label{chap.hardware}

\setcounter{section}{19}

\section{Test section one}
\subsection{test section one one}
\subsection{test section one two}

\section{Test section two}
\subsection{test section two one}
\subsection{test section two two}

%%%% Appendix
\cleardoublepage
\phantomsection
\appendix
\chapter*{Appendix}

%%% Configure de distance

\chapter{Appendix Test Chapter}

\setcounter{section}{199}
\section{Test Section}

%%%%%%%%%%%%%%%% Annex:
\cleardoublepage
\phantomsection
\setcounter{chapter}{0}
\renewcommand{\theHchapter}{an.\Alph{chapter}}
\renewcommand{\thechapter}{$\,\!$\Alph{chapter}}

\renewcommand{\appendixname}{Annex}
\renewcommand{\thesection}{\thechapter$_{x}$.\arabic{section}}