I am using the "setspace" package to format my document with double spacing (requirement for an assignment).
One of my section headers takes up two lines, though, and these section headers look better with single spacing.
I went ahead and fixed it with the following.
Nunc venenatis nulla eu arcu pellentesque eu molestie nunc condimentum.
Donec sodales lacinia dictum.
Sed aliquam turpis quis enim bibendum pharetra.
This is the last paragraph in section i.
\singlespace
\section{The Next Section Which Has a Fairly Long Name that Stretches Over Two Lines}
\doublespace
This is the first paragraph in section i+1.
Cras ut tortor vel dui ultricies dapibus vitae sit amet nisi.
Aliquam rhoncus leo id eros volutpat faucibus.
Integer lectus elit, varius et semper eget, tristique vel odio.
This is the only case (so far) in my paper where the heading requires two lines, so it's not a big deal to fix it with this hack.
However, I can imagine as the paper gets longer and has more sections, it could become more tedious to add this hack multiple times.
Is there any way I can indicate once that section headings should be single-spaced and paragraphs should be double-spaced, rather than adding this hack multiple times throughout my document?
Best Answer
You can use the
etoolbox
package to insert\singlespacing
just before the sectional units, and then to append\doublespacing
:This will apply to
\section
,\subsection
,\subsubsection
.Another option is to use the
titlesec
package:Or, using the reduced syntax:
By the way, the
setspace
package provides several commands and environments; the commands (switches) end in "ing":\singlespacing
,\onehalfspacing
,\doublespacing
, whereas the environments aresinglespace
,onehalfspace
,doublespace
.Using
\doublespace
are you are doing (as a switch) is not entirely correct; the following simple document:when processed will show in the output console a message
which indicates that a group started but was never ended (in this case, the group created by the
\doublespace
command associated to the environmentdoublespace
). The correct form of using the switch isand, for the corresponding environment: