目次での表示方法に影響を与えずに、セクション見出しの形式を変更するにはどうすればよいですか?

目次での表示方法に影響を与えずに、セクション見出しの形式を変更するにはどうすればよいですか?

私の文書には次のような例があります:

\section{\large Multi-worded section heading }

現在、目次では、他のすべてのタイトルよりも大きく表示されています (LaTeX にそのように指示したためであることは間違いありません)。これを他のタイトルと同じになるように変更するにはどうすればよいでしょうか。

答え1

私はこれを、セクションタイトルの1つまたはいくつかだけ(すべてではなく)フォントを変更したいと理解しました。最も簡単な方法は、\section次のようなオプションの引数を使用することです。

%\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}

ここに画像の説明を入力してください

これらの変更をすべてのセクションに適用したい場合は、sectstyWerner がリンクしている次の方法を使用するとよいでしょう。セクション内では小文字大文字だが目次では小文字大文字ではないまたはtitlesecパッケージ(titleformat*{\section}{\Huge})を使用します。

関連情報