![目录显示不正确](https://linux22.com/image/425854/%E7%9B%AE%E5%BD%95%E6%98%BE%E7%A4%BA%E4%B8%8D%E6%AD%A3%E7%A1%AE.png)
有人知道怎么解决这个问题吗?问题是当数字达到 10 时,数字非常接近标题。我会添加一张图片来参考。提前谢谢!
这些是我使用的所有软件包(以及文档类型):
\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}
注意:问题是相关的,但该解决方案并不完美,因为它会改变间距并删除数字后的句点。我只想更改数字和标题之间的空格。谢谢!
编辑:添加 MWE:
\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}
\setlength\headheight{0pt}
\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}
这将显示:
答案1
解决方案与目录中的罗马数字变得“太宽”,除了对包加载进行一些调整外:
\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}
您还可以通过修补手动调整间距\l@section
:
\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@section}% <cmd>
{1.5em}% <search>
{2em}% <replace>
{}{}% <success><failure>
\makeatother
答案2
使用tocloft
包并\cftsecnumwidth
更改目录中章节编号的空间。
编辑
更改了答案以满足 OP 的愿望(在评论中),希望在目录条目之间留出额外的空间。
% 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}{}[
\addcontentsline{toc}{section}{\thesection~#1}]
\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}