內容標題的格式與章節標題相同

內容標題的格式與章節標題相同

如何使節標題看起來\tableofcontents與使用以下命令格式化的常規節標題相同titlesec

\titleformat{\section}{\Large\scshape}{\thesection. }{}{}
\titlespacing*{\section}{0pt}{1em}{0.4em}

第一行主要使章節標題使用小型大寫字母,第二行設定它們周圍的間距。

因此部分標題隨後如下所示:

標題格式正確

我希望同樣的事情發生在我的目錄中——目前看起來像這樣:

乳膠格式的常規格式目錄,標有我希望的外觀

一個最小的工作範例:

\documentclass{article}

\usepackage{titlesec}

% format section title
\titleformat{\section}{\Large\scshape}{\thesection. }{}{}

% set section titles spacing
\titlespacing*{\section}{0pt}{1em}{0.4em}

% also format subsection title
\titleformat{\subsection}{\scshape}{\thesubsection. }{}{} 

\begin{document}

\tableofcontents

\section{One}
\subsection{SubOne}
\subsection{SubTwo}
\section{Two}
\section{Three}

\end{document}

任何幫助將不勝感激 - 謝謝!

答案1

目錄的格式可以自訂titletoc, 的同伴titlesec

\documentclass{article}

\usepackage{titlesec}
\usepackage{titletoc}

% format section title
\titleformat{\section}{\Large\scshape}{\thesection.}{.5em}{}
% set section titles spacing
\titlespacing*{\section}{0pt}{1em}{0.4em}
% set section titles in TOC
\titlecontents{section}[1.5em]{\scshape}{\contentslabel{1.5em}}{}{}

% also format subsection title
\titleformat{\subsection}{\scshape}{\thesubsection.}{.5em}{}
% format subsection titles in TOC
\dottedcontents{subsection}[3.8em]{\scshape}{2.3em}{.6pc}

\begin{document}

\tableofcontents

\section{One}
\subsection{SubOne}
\subsection{SubTwo}
\section{Two}
\section{Three}

\end{document}

相關內容