![如何更改一節標題的格式而不影響其在目錄中的顯示方式?](https://rvso.com/image/298831/%E5%A6%82%E4%BD%95%E6%9B%B4%E6%94%B9%E4%B8%80%E7%AF%80%E6%A8%99%E9%A1%8C%E7%9A%84%E6%A0%BC%E5%BC%8F%E8%80%8C%E4%B8%8D%E5%BD%B1%E9%9F%BF%E5%85%B6%E5%9C%A8%E7%9B%AE%E9%8C%84%E4%B8%AD%E7%9A%84%E9%A1%AF%E7%A4%BA%E6%96%B9%E5%BC%8F%EF%BC%9F.png)
在我的文檔中的一個實例中,我有以下內容:
\section{\large Multi-worded section heading }
目前在目錄中,它看起來比所有其他標題都大(毫無疑問,因為這就是我指示 LaTeX 執行的操作)。我如何更改它,使其與其他標題相同?
答案1
我的理解是:您只想更改一個/幾個部分標題中的字體(並非全部)。最簡單的方法是使用\section
like的可選參數
%\section[optional content]{regular content }
\section[Multi-worded section heading]{\large Multi-worded section heading }
以便可選的未格式化內容用於運行標題和目錄。這是帶有類別的 MWE article
(你沒有告訴哪個類別!)
\documentclass{article}
\begin{document}
\tableofcontents
\section{Some section}
\section[A section]{\Huge A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\section{Some section again}
\end{document}
如果節數較小,這看起來肯定很難看。更好的方法是定義一個新命令,例如:
\makeatletter
\newcommand\mysection{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Huge\bfseries}} %%<-- \Large replaced by \Huge
\makeatother
並按如下方式使用它:
\documentclass{article}
\makeatletter
\newcommand\mysection{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Huge\bfseries}}
\makeatother
\begin{document}
\tableofcontents
\section{Some section}
\mysection{A section}
\subsection{A subsection}
\subsubsection{A subsubsection}
\section{Some section again}
\end{document}
如果您想將這些變更套用到所有部分,您最好使用sectsty
(如 Werner 連結:部分使用小寫字母,但目錄中不使用小寫字母或使用titlesec
包( titleformat*{\section}{\Huge}
)。