Document Classessingle spacing for headings but double spacing for text

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
User avatar
seano
Posts: 12
Joined: Tue Jan 29, 2008 3:38 pm

single spacing for headings but double spacing for text

Post by seano »

Hi All,
I am using the setspace package to double space my document. Unfortunately, this also formats the chapter and section headings to be double spaced which, because of the large font size, leaves a LOT of space between the lines.

Is there an easy way to work around this?

I have checked the setspace.sty file (version 6.7) but there were no clues there.
I realise that I could use the \singlespacing and \doublespacing commands before and after each heading, but there's surely got to be a more intelligent way to do it...

My document currently looks something like this:

Code: Select all

\documentclass{book}
\usepackage{setspace}
\begin{document}
%
   \include{front_page}
   \include{acknowledgements}
   \tableofcontents{}
%   
   \doublespacing
   \include{chapter1}
   \include{chapter2}
   \include{chapter3}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: single spacing for headings but double spacing for text

Post by balf »

You might include the \singlespacing and \doublespacing commands in a re-definition of your section headings once and for all, using titlesec for that purpose.

B.A.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

single spacing for headings but double spacing for text

Post by localghost »

If not part of strong demands, double spacing should be avoided. For the present you could define some kind of environment that switches to single spacing, starts the section and then switches back to double spacing or use something like titlesec. As a German user you may take a look at the KOMA Script Bundle.


Best regards
Thorsten
User avatar
seano
Posts: 12
Joined: Tue Jan 29, 2008 3:38 pm

single spacing for headings but double spacing for text

Post by seano »

titlesec looks like it will do what I want, but only if I redefine all of the heading properties, which I don't particularly want to do: I like the defaults as they are and I would prefer to make as few changes as possible (sorry: I have too much experience with Word and still expect LaTeX to have a meltdown at some point)

Is there any way to get the \titleformat command to redefine some aspects of the formatting, but use the default values defined in the .cls file for other aspects?

The syntax of the \titleformat command is:

Code: Select all

\titleformat{cmd}[shape]{format}{label}{sep}{before-code}[after-code]
What I want to do is keep the default formatting from the .cls file (not the defaults from the titlesec package) but add "before-code" and "after-code". I have tried:

Code: Select all

\titleformat{\section}[]{}{}{}{begin{singlespacing}}[end{singlespacing}]
but that just made TeX angry (i.e. lots of errors)

Is there a "value" that you can enter to say "don't change anything" rather than just "default"?

Or does anybody have a better idea?

Thanks.
Donald E. Knuth said that TeX was intended for the creation of beautiful books.
The plethora of confused, frustrated PhD students trying to use it must therefore be seen as an unintentional side effect.
Post Reply