如何增加目录中编号和文本之间的间距?请注意,我正在使用类article
并使用\addcontentsline{toc}.
代码:
\documentclass[12pt]{article}
\newcounter{chapternum}
\newcounter{examplenum}
\newcommand{\example}{\stepcounter{examplenum} \noindent{\large{\color{Red}{Example \theexamplenum: }}}\addcontentsline{toc}{subsubsection}{Example \theexamplenum}}
\renewcommand\thesection{\thechapternum.\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\begin{document}
\stepcounter{chapternum}
\tableofcontents %Ignore the page numbers; the picture is a screenshot from my document and this code is a MWE.
\section{Sets}
\subsection{Introduction to Sets}
\subsection{Union and Intersection}
\example
\subsection{Special Sets}
\subsection{Interval Notation}
\example
\end{document}
答案1
您可以使用tocloft
和调整这些
\setlength{\cftsecnumwidth}{2em} %% adjust
\cftsetindents{subsection}{2em}{3em} %% adjust
\cftsetindents{subsubsection}{5em}{4em} %% adjust
这\cftsecnumwidth
是排版章节编号的框的宽度。摘自tocloft
手册(第 10 页):
代码
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{tocloft}
\newcounter{chapternum}
\newcounter{examplenum}
\newcommand{\example}{\stepcounter{examplenum} \noindent{\large{\color{red}{Example \theexamplenum: }}}\addcontentsline{toc}{subsubsection}{Example \theexamplenum}}
\renewcommand\thesection{\thechapternum.\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\setlength{\cftsecnumwidth}{2em}
\cftsetindents{subsection}{2em}{3em}
\cftsetindents{subsubsection}{5em}{4em}
\begin{document}
\stepcounter{chapternum}
\tableofcontents %Ignore the page numbers; the picture is a screenshot from my document and this code is a MWE.
\section{Sets}
\subsection{Introduction to Sets}
\subsection{Union and Intersection}
\example
\subsection{Special Sets}
\subsection{Interval Notation}
\example
\end{document}