I'm using the titlesec package to format my (sub)section titles. I'd like to use the runin
option in \titleformat
to place my subsections titles within the first paragraph of each subsection. However, when I do this, I get extra spacing after the first line of each subsection. I've fiddled with the the options in \titlespacing
and none of them seem to fix the problem.
\documentclass[11pt]{article}
\usepackage{titlesec}
\titleformat{\section}{\normalfont\fontsize{11}{36}\bfseries}{\thesection.}{0.25em}{}
\titlespacing{\section}{0em}{-1.0em}{-2.0em} % {left}{before}{after}[right]
\renewcommand{\thesubsection}{\thesection.\alph{subsection}}
\titleformat{\subsection}[runin]{\normalfont\fontsize{11}{36}\bfseries\slshape}{\thesubsection.}{0.25em}{}
\titlespacing{\subsection}{0.0em}{0.0em}{0.5em} % {left}{before}{after}[right]
\linespread{1}
\begin{document}
\section{The first section}
\subsection{The first subsection within the first section:} Asdf asdf asdf asdf asdf asdf adsf asdf asdf asdf adf adf adsf adsf adsf asdf asdf asdf asd f. Wert qwer qwer qwer qwer qwer qwer qewr qewr erwq erw erw rewr rew re ewq ewr wqr qwer weq rqwe r re qwe reqw r ewe r we e w er qwe rq we rqwer qwer qw erq er qewr we are qew rq ew r ew. Hkjlkljj h jlkjh lkjlk jlhlkh lhkjljkj lklkk.
\subsection{The second subsection within the first section:} Asdf asdf asdf asdf asdf asdf adsf asdf asdf asdf adf adf adsf adsf adsf asdf asdf asdf asd f. Wert qwer qwer qwer qwer qwer qwer qewr qewr erwq erw erw rewr rew re ewq ewr wqr qwer weq rqwe r re qwe reqw r ewe r we e w er qwe rq we rqwer qwer qw erq er qewr we are qew rq ew r ew. Hkjlkljj h jlkjh lkjlk jlhlkh lhkjljkj lklkk.
\end{document}
Any suggestions?
Best Answer
The spacing you are getting is due to the way you have specified the fontsize: the
\fontsize
arguments are the actual fontsize and the leading which is (roughly) the height of a line. (See What exactly is leading? for extensive discussion.) You've made this 36 pt in your sectioning commands, which means each line is approximately 3 times the character height. So you should use a normal leading for the fontsize commands and then use thetitlesec
spacing commands to adjust the spacing. To do this I've just added\normalsize
to your sectioning commands. I don't know what spacing you actually want, but this example should allow you to change the spacing appropriately. I've also usedex
as the unit for vertical height instead ofem
which is typically a measure of horizontal height. (This mainly matters if you are using a font in which the two values are quite different, but it's a good habit to get into.)It's also not a good idea to mess with
\linespread
; if you need things like double spacing and 1/2 spacing in a document, use thesetspace
package.