I am typesetting a thesis using the book
class and need the chapter titles to be single-spaced while the main text must be double-spaced.
Inserting \singlespacing
before the text in the definition of the chapter creates ! Missing control sequence inserted. <inserted text> \inaccessible
errors on compiling, and also inserts a spurious newline between the chapter numbers and names in the table of contents.
Here is a minimum working example:
\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}
This is not a duplicate of this question, as the answers to that question involve either specific hacks to the \section
commands, or the titlesec
package which gives the error ! Package titlesec Error: Not allowed in 'easy' settings.
when I attempt to use it with the book
class.
Edit: it turns out that sectsty
is unsuitable for my needs as it disrupts formatting elsewhere and interacts with doublespacing
differently than using the titlesec
solution. For example,
\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}
Best Answer
You could add the following instructions to the document's preamble (after loading the
setspace
package):A full MWE (minimum working example):