
我正在整理一份報告,作為物理學位部分小組專案的一部分,我一直在嘗試正確格式化目錄格式,這很有趣。這是一個 MWE:
\documentclass[twoside]{article}
\usepackage[a4paper,pdftex,left=1.7cm,right=1.7cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage{blindtext}
\usepackage[english]{babel}
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
\begin{document}
\tableofcontents
\addtocontents{toc}{~\hfill\textbf{Page}\par}
\newpage
\begin{abstract}
\blindtext
\end{abstract}
\section{A section}
\blindtext
\section{Another section}
\blindtext
\subsection{A subsection}
\blindtext
\subsection{Yet another subsection}
\blindtext
\subsubsection{Oh, exciting, a sub sub section!}
\blindtext
\section{Another boring old section}
\blindtext
\end{document}
輸出如下:
不錯,除了各部分之間的間距及其各自的數量太小之外。我嘗試透過在序言中包含此內容來修復它:
\makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{3em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{3.0em}{3.5em}}
\renewcommand{\l@subsubsection}{\@dottedtocline{3}{4.5em}{4.2em}}
\makeatother
給出這個:
雖然它允許我根據自己的喜好調整間距(圖片中沒有正確調整,只是一個例子),但我似乎失去了粗體字體,並為我的部分獲得了一些以前沒有的點。我還失去了部分之間的良好間距。我嘗試恢復粗體字體
\renewcommand\cftsecfont{\bfseries}
但似乎沒有任何效果。任何有關如何更好地格式化我的目錄的建議將不勝感激。我不必遵守大學指定的任何特定格式佈局,但我確實希望它看起來清晰且專業。第一個例子是完美的,除了部分編號緊挨著部分之外,儘管對於小節來說這很好。
答案1
(文章類)中用於節號的寬度Toc
可以透過重新調整來設定
\cftsecnumwidth
到適當的值(30pt
在我的例子中)。
tocloft
為此需要該包。
我不明白的目的
\renewcommand*\thesection{\arabic{section}.0}
然而。
\documentclass[twoside]{article}
\usepackage[a4paper,pdftex,left=1.7cm,right=1.7cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage{blindtext}
\usepackage[english]{babel}
\usepackage{tocloft}
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand{\cftsecnumwidth}{30pt}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{4}
\begin{document}
\tableofcontents
\addtocontents{toc}{~\hfill\textbf{Page}\par}
\newpage
\begin{abstract}
\blindtext
\end{abstract}
\section{A section}
\blindtext
\section{Another section}
\blindtext
\subsection{A subsection}
\blindtext
\subsection{Yet another subsection}
\blindtext
\subsubsection{Oh, exciting, a sub sub section!}
\blindtext
\section{Another boring old section}
\blindtext
\end{document}