我怎样才能以这种方式调整 \tableofcontents ?
\documentclass[12pt,a4paper,x11names]{article}
\usepackage[spanish]{babel}
\usepackage{lipsum}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\newpage
Here stars the document... after the index\\
\part{Part I One}
\blindtext
\section{Section A of I}
\blindtext
\subsection{Subesction Jei}
\blindtext
\subsection{Subesction Jeii}
\blindtext
\section{Section B of I}
\blindtext
\subsection{Subesction Jeiii}
\blindtext
\subsection{Subesction Jeiiiii}
\blindtext
\section{Section C of I}
\blindtext
\subsection{Subesction Jeei}
\blindtext
\subsection{Subesction Jeeei}
\blindtext
\part{Part II Two}
\blindtext
\subsection{Subesction Jeeeei}
\blindtext
\section{Section A of II}
\blindtext
\subsection{Subesction Jerr}
\blindtext
\subsection{Subesction Jeddd}
\blindtext
\section{Section B of II}
\blindtext
\subsection{Subesction Jesss}
\part{Part III Three}
\blindtext
\section{Section A of III}
\subsection{Subesction Jerr}
\section{Section B of III}
\blindtext
\subsection{Subesction Jer}
\part{Part IV Four}
\section{Section A of IV}
\blindtext
\subsection{Subesction Jeittiii}
\blindtext\subsection{Subesction Jeiit}
\blindtext
\end{document}
答案1
您可以使用
\usepackage{chngcntr}
\counterwithin{section}{part}
由于使用罗马数字表示部分内容会导致章节和小节条目的数字和标题之间几乎没有空间,因此需要进行一些额外的调整,这可以使用包轻松完成tocloft
(根据需要调整长度):
\usepackage{tocloft}
\cftsetindents{section}{0em}{2.5em}
\cftsetindents{subsection}{2.5em}{3.5em}
完整示例:
\documentclass[12pt,a4paper,x11names]{article}
\usepackage[spanish]{babel}
\usepackage{tocloft}
\usepackage{chngcntr}
\counterwithin{section}{part}
\cftsetindents{section}{0em}{2.5em}
\cftsetindents{subsection}{2.5em}{3.5em}
\begin{document}
\tableofcontents
\newpage
Here stars the document... after the index\\
\part{Part I One}
\section{Section A of I}
\subsection{Subesction Jei}
\subsection{Subesction Jeii}
\section{Section B of I}
\subsection{Subesction Jeiii}
\subsection{Subesction Jeiiiii}
\section{Section C of I}
\subsection{Subesction Jeei}
\subsection{Subesction Jeeei}
\part{Part II Two}
\subsection{Subesction Jeeeei}
\section{Section A of II}
\subsection{Subesction Jerr}
\subsection{Subesction Jeddd}
\section{Section B of II}
\subsection{Subesction Jesss}
\part{Part III Three}
\section{Section A of III}
\subsection{Subesction Jerr}
\section{Section B of III}
\subsection{Subesction Jer}
\part{Part IV Four}
\section{Section A of IV}
\subsection{Subesction Jeittiii}
\subsection{Subesction Jeiit}
\end{document}