Document ClassesSingle spaced headings double space text (setspace/titlesec)

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
leh00
Posts: 3
Joined: Fri Dec 12, 2008 7:58 pm

Single spaced headings double space text (setspace/titlesec)

Post by leh00 »

Use of setspace and titlesec packages to create single space headings and double space text??

Hi

I have started to use LaTeX to write my PhD thesis with and I am adapting a class file provided by the university to match my departments requirements and personal taste for the bits that aren't defined. The class file is an adaptation of the report class.

The main problem I have is that I have to have the main body text of the chapters double spaced, for this I believe the best package is 'setspace' but I only need it to apply to the body text not to the chapter headings or any of the front matter e.g. TOC, acknowledgements page, declaration of originality etc. I currently have the font size and spacing/layout of my titles defined using the 'Titlesec' package.

So my question is how do I apply the double spacing just to the body text of chapters:
--Is there an environment defined for this text and can I add the \doublespace command to just this
--or can I add the \singlespace setting or something similar to my section headings definitions using the titlesec package then add \single space to each environment i have defined to layout the abstract page etc

The code i have just to define my chapter and section headings is below:

Code: Select all

\usepackage{titlesec}

\titleformat{\chapter}[display] %[display] puts the title chapter on a separate line
 {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titleformat{\section}
 {\normalfont\large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
 {\normalfont\normalsize\bfseries}{\thesubsection}{1em}{} %bfseries to add bold style
\titleformat{\subsubsection}
 {\normalfont\normalsize\mdseries\itshape}{\thesubsubsection}{1em}{}  %itshape to add an italic style, mdseries to turn off bold

%paragraph and subparagraph not numbered
\titleformat{\paragraph}[runin] % [runin] indents the first line of the paragraph 
 {\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[runin]
 {\normalfont\normalsize\bfseries}{\thesubparagraph}{1em}{}

%To set section heading spacings

\titlespacing*{\chapter}{0pt}{5pt}{25pt}
\titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\paragraph} {0pt}{3.25ex plus 1ex minus .2ex}{1em}
\titlespacing*{\subparagraph} {\parindent}{3.25ex plus 1ex minus .2ex}{1em}
and example of the code i have used to define each front matter page e.g. acknowledgements page

Code: Select all

\newenvironment{acknowledgements}
{\begin{alwayssingle} \thispagestyle{empty}
\begin{center}
\vspace*{1.5cm}
{\huge \bfseries Acknowledgements}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}
I know i could just add the /doublespace command as I start each section of body text but there must be a more elegant solution than this?

Many thanks in advance
leh00

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Single spaced headings double space text (setspace/titlesec)

Post by phi »

Hallo,

you already gave the answer in your post:
or can I add the \singlespace setting or something similar to my section headings definitions using the titlesec package then add \single space to each environment i have defined to layout the abstract page etc
Yes, exactly that. You just have to add \singlespacing where you want it, i.e., the definition of the environments and the title format given in the second required argument to the \titleformat command:

Code: Select all

\documentclass{article}

\usepackage[onehalfspacing]{setspace}
\usepackage{titlesec}
\usepackage{lipsum}

\titleformat{\section}
{\normalfont\large\bfseries\singlespacing}{\thesection}{1em}{}

\newenvironment{alwayssingle}{}{}

\newenvironment{acknowledgements}
{\begin{alwayssingle}\singlespacing\thispagestyle{empty}
\begin{center}
\vspace*{1.5cm}
{\huge \bfseries Acknowledgements}
\end{center}
\vspace{0.5cm}
\begin{quote}}
{\end{quote}\end{alwayssingle}}


\begin{document}

\begin{acknowledgements}
\lipsum[1]
\end{acknowledgements}


\section{\lipsum[1]}

\lipsum


\end{document}
If you want to have single spacing in a certain region, you can also use the environment singlespace:

Code: Select all

\begin{singlespace}
text
\end{singlespace}
leh00
Posts: 3
Joined: Fri Dec 12, 2008 7:58 pm

Re: Single spaced headings double space text (setspace/titlesec)

Post by leh00 »

Thank you for such a quick reply, before I just hadn't quite managed to get the \singlespace command in the right place in the \titlesec code so all I was getting were error messages. It is working perfectly now. :)

Many thanks

leh00
Post Reply