
Estou compondo uma tese usando a book
classe e preciso que os títulos dos capítulos tenham espaço simples, enquanto o texto principal deve ter espaço duplo.
Inserir \singlespacing
antes do texto na definição do capítulo cria ! Missing control sequence inserted. <inserted text> \inaccessible
erros na compilação e também insere uma nova linha falsa entre os números dos capítulos e nomes no índice analítico.
Aqui está um exemplo mínimo de trabalho:
\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}
Esta não é uma duplicata deessa questão, já que as respostas a essa pergunta envolvem hacks específicos para os \section
comandos ou o titlesec
pacote que apresenta o erro ! Package titlesec Error: Not allowed in 'easy' settings.
quando tento usá-lo com a book
classe.
Editar: acontece que isso sectsty
é inadequado para minhas necessidades, pois atrapalha a formatação em outro lugar e interage de doublespacing
maneira diferente do uso da titlesec
solução. Por exemplo,
\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}
Responder1
Você poderia adicionar as seguintes instruções ao preâmbulo do documento (depois de carregar o setspace
pacote):
\usepackage{sectsty}
\allsectionsfont{\singlespacing}
Um MWE completo (exemplo mínimo de trabalho):
\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}
Responder2
Uma pergunta relacionadatem uma solução para títulos de seção usando o titlesec
pacote. No entanto, se esta resposta for copiada e modificada ingenuamente nos títulos dos capítulos, isso resultará em um ! Package titlesec Error: Not allowed in 'easy' settings
erro. O erro surge porque oO pacote titlesec funciona de maneira um pouco diferente com capítulos e seções. Um encantamento para capítulos com espaço único e cabeçalhos de seção usando o titlesec
pacote é o seguinte:
\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}{}