I want to create a TOC, that will have equal margins between section numbers and section titles regardless of the number of digits in section number.
I have an example of solution, but I want to use titlesec
to define my sections.
\renewcommand{\subsection}[1]
{%
\refstepcounter{subsection}%
\vskip 1.5ex%
{\bf\thesubsection \ #1}%
\addcontentsline{toc}{subsection{\hspace{1em}\thesubsection\hspace{0.5em}#1}%
\vskip 1.5ex %
}%
Here is my try with titletoc
It's seems to be right, but I can have a huge amount of sections and subsections in my document, so the reserved space will end up soon.
\documentclass{article}
\usepackage{titletoc}
\dottedcontents{subsection}[3.5em]{}{3.2em}{1pc}
\begin{document}
\tableofcontents
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\subsection{Subsection1}
\subsection{Subsection2}
\subsection{Subsection3}
\subsection{Subsection4}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\end{document}
MWE with redefined subsection:
\documentclass{article}
\renewcommand{\subsection}[1]
{%
\refstepcounter{subsection}%
\vskip 1.5ex%
{\bf\thesubsection \ #1}%
\addcontentsline{toc}{subsection}{\hspace{1em}\thesubsection\hspace{0.5em}#1}%
\vskip 1.5ex %
}%
\begin{document}
\tableofcontents
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\section{Section}
\subsection{Subsection1}
\subsection{Subsection2}
\subsection{Subsection3}
\subsection{Subsection4}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\subsection{SubsectionN}
\end{document}
titlesec
for your subsections? On the other hand, I don't understand very well the problem with usingtitletoc
?titlesec
for my subsections, but I suppressed my subsections definitions to show only TOC.titletoc
is that I can't understand how to set equal margins between section number and section title with it.10
andSection
is not the same as between9
and its title?