
我正在使用該類排版論文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
不適合我的需求,因為它會破壞其他地方的格式,並且doublespacing
與使用titlesec
解決方案的方式互動。例如,
\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}{}