ダブルスペースの文書にシングルスペースの章タイトルを付ける

ダブルスペースの文書にシングルスペースの章タイトルを付ける

私はクラスを使用して論文をタイプセットしていますbookが、章のタイトルはシングルスペースで、本文はダブルスペースにする必要があります。

\singlespacing章の定義のテキストの前に挿入すると! Missing control sequence inserted. <inserted text> \inaccessible、コンパイル時にエラーが発生し、目次の章番号と名前の間に誤った改行が挿入されます。

以下に最小限の動作例を示します。

\documentclass[12pt,oneside]{book}
\usepackage{lipsum} % included only to generate example text
\usepackage{setspace} % set double vs single spacing
\begin{document}
\clearpage
\doublespacing
\chapter{I need singlespace titles, doublespace text.}
\section{Section headers should also be single-spaced, but I could adjust titles to fit on one line}
\lipsum[4] % generate some filler text
\end{document}

これは重複ではありませんこの質問その質問に対する答えには、\sectionコマンドに対する特定のハック、またはクラスで使用しようとしたときにtitlesecエラーが発生するパッケージのいずれかが関係しているためです。! Package titlesec Error: Not allowed in 'easy' settings.book

編集: 他の場所での書式設定を乱し、ソリューションを使用する場合とは異なる方法sectstyで相互作用するため、これは私のニーズには適していないことがわかりました。たとえば、doublespacingtitlesec

\documentclass[12pt,oneside]{book}
\usepackage{lipsum}
\setcounter{secnumdepth}{3}
\usepackage{sectsty}
\usepackage{setspace} % set double vs single spacing
\allsectionsfont{\singlespacing}
\begin{document}
\doublespacing
\chapter{Singlespace titles, doublespace text.}
\section{Section headers should \\also be single-spaced}
\subsubsection{The \texttt{sectsty} package interacts with \texttt{doublespacing}, adds too much space below this header}
\paragraph{The \texttt{sectsty} package causes this paragraph to be indented}
\lipsum[4]
\end{document}

答え1

ドキュメントのプリアンブルに次の指示を追加できます (setspaceパッケージをロードした後)。

\usepackage{sectsty}
\allsectionsfont{\singlespacing}

完全な MWE (最小限の動作例):

\documentclass[12pt,oneside]{book}
\usepackage{lipsum}   % for filler text
\usepackage{setspace} 
\doublespacing

\usepackage{sectsty}
\allsectionsfont{\singlespacing}

\begin{document}

\chapter{I need singlespace titles, doublespace text.}

\section{Section headers should also be single-spaced, but I could adjust titles to fit on one line}

\lipsum[4] % filler text
\end{document}

答え2

関連する質問パッケージを使用したセクション見出しの解決策がありますtitlesec。ただし、この回答をコピーして単純に章見出し用に修正すると、! Package titlesec Error: Not allowed in 'easy' settingsエラーが発生します。エラーが発生するのは、titlesecパッケージは、章とセクションとでは少し異なる動作をします。このパッケージを使用して章とセクションのヘッダーをシングルスペースにするための呪文はtitlesec次のとおりです。

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries\singlespacing}{\chaptertitlename\ \thechapter}{40pt}{\huge}
\titleformat{\section}{\singlespacing\normalfont\Large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\singlespacing\normalfont\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\singlespacing\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}

関連情報