Anyone knows how to solve this? The problem is that the number is very close to the title when the number reaches 10. I will add an image to reference this. Thanks in advance!

These are all the packages (and the type of document) I used:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{cite}
\usepackage{float}
\usepackage[final]{hyperref}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage[spanish]{babel}
\usepackage[bottom]{footmisc}
\usepackage{titlesec}
\usepackage{hyperref}
\usepackage{soul}
\usepackage{comment}
\usepackage{subfiles}


NOTE: This question is related but that solution doesn't work perfectly because it changes the spacing and removes the period after the number. I only want to change that space between number and title. Thanks!

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\usepackage{cite}
\usepackage{float}
\usepackage[final]{hyperref}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage[spanish]{babel}
\setlength{\parindent}{0em}
\setlength{\parskip}{.5em}
\renewcommand{\baselinestretch}{1.35}
\usepackage[bottom]{footmisc}
\usepackage{titlesec}
\usepackage{hyperref}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}

\begin{document}

\thispagestyle{empty}
\begin{center}
{\Large\bfseries Resume\par}
\vspace{0.5cm}
\end{center}

\tableofcontents
\pagebreak

\section{A}
\section{B}
\section{C}
\section{D}
\section{E}
\section{F}
\section{G}
\section{H}
\section{I}
\section{J}
\section{K}
\section{L}
\section{M}

\end{document}


This will display:

• How does the rest of your code look? Dec 17, 2020 at 18:08
• You mention a solution to adifferent question, but this question has a total of 7 different answers. Which of them did you try? Please also prepare a minimal working example (MWE) that allows others to reproduce the output you get. Dec 17, 2020 at 18:10
• Added MWE. Thanks and sorry, this is my first time! Dec 17, 2020 at 18:18
• Yeah that solves the problem of the period. Do you know how to set the indent and the spacing as before? Because that package changes the indentation of the table of contents. If you can test it so you will understand me! Thanks!!!! Dec 17, 2020 at 18:30

\documentclass{article}

\usepackage{tocloft}
\usepackage[spanish]{babel}
\usepackage{hyperref}

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\setlength{\cftsecnumwidth}{3em}

\begin{document}

\tableofcontents

\clearpage

\section{A}
\subsection{AA}
\section{B}
\section{C}
\section{D}
\section{E}
\section{F}
\section{G}
\section{H}
\section{I}
\section{J}
\section{K}
\section{L}
\section{M}

\end{document}


You can also adjust the spacing manually by patching \l@section:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}% <cmd>
{1.5em}% <search>
{2em}% <replace>
{}{}% <success><failure>
\makeatother

• The spacing is completely separate from the indentation. You can adjust \baselinestretch or use setspace (latter is preferred).
– Werner
Dec 17, 2020 at 18:57
• How can I change the spacing as before? Or the only solution is that I need to play around with setspace? Dec 17, 2020 at 19:03
• @santilococo: You can use your previous settings: \setlength{\parskip}{.5em} \renewcommand{\baselinestretch}{1.35} if you wish.
– Werner
Dec 17, 2020 at 19:06
• But it isn't as before. Do you know why? Dec 17, 2020 at 19:36
• @santilococo: tocloft does manage all of the ToC content; even setting the vertical spacing between certain elements. Try adding \setlength{\cftparskip}{.5em} \addtolength{\cftbeforesecskip}{.5em} as part of your settings. It specifies the \parskip within the ToC and the skip before a section. You can adjust it to suit your needs.
– Werner
Dec 17, 2020 at 19:54

Use the tocloft package and \cftsecnumwidth to change the space for section numbers in the ToC.

EDIT

Changed the answer to meet the OP's desire (in a comment) to have extra space between the ToC entries.

% tocnumprob.tex rev 2 SE 575762

\documentclass{article}
\usepackage{comment}

\begin{comment}
\usepackage[explicit]{titlesec}

\titleformat{name=\section}[block]
{\normalfont\normalsize\bfseries}{\thesection~~#1}{1em}{}[
\end{comment}

\usepackage{tocloft}
%\setlength{\cftsecnumwidth}{3.5em}  % change this to suit more space for section numbers
\makeatletter
\renewcommand{\numberline}[1]{%    % don't put section numbers in a box
{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
\makeatother
\renewcommand{\cftsecaftersnum}{\hspace{1em}} % change this to suit space after section number

\setlength{\cftparskip}{\baselineskip} % put more space between entries

\begin{document}

\tableofcontents
\pagebreak

\section{A}
\section{B}
\section{C}
\section{D}
\section{E}
\section{F}
\section{G}
\section{H}
\section{I}
\section{J}
\section{K}
\section{L}
\section{M}
\subsection{Subsection}
\end{document}

\section{Fisrt}
\setcounter{section}{98999}
\section{section}

\end{document}


• Thanks, but do you know why the spacing also changes and what should I do to change it back to the "original"? Because it doesn't use the length that I described in the preamble. Dec 17, 2020 at 19:01
• @santilococo What spacing? What original? Dec 18, 2020 at 18:15
• I mean the line spacing. Run the MWE without tcloft and then run it with your code and you will see what I mean. It's silly but I can't fix it. Dec 19, 2020 at 20:13
• @santilococo I have updated my answer to deal with your latest request. --- GOM Dec 22, 2020 at 19:28