6

I have a two-column document that uses the titlesec package with the compact option. This mostly produces the spacing that I like, but it doesn't give enough stretchability above the section titles which leads to underfull vboxes and spaces between paragraphs. It is especially noticeable in pages that have full-width floats and only one column of text has a heading (e.g., \paragraph).

Is there any easy way to increase the stretchability without just guessing values for \titlespacing?

Minimal example.

\documentclass{article}
\usepackage[compact]{titlesec}
\usepackage{lipsum}
\beforetitleunit=1in % lockstep's suggestion (more or less)
\begin{document}
\section{A}
\lipsum[1]
\subsection{B}
\lipsum[2]
\subsubsection{C}
\lipsum[3]
\paragraph{D}
\lipsum[4]
\end{document}
3
  • Does an explicit \titlespacing{\section}{big stretchy}{big stretchy} not work? (with appropriate values substituted for "big stretchy")
    – Seamus
    Commented Feb 9, 2011 at 10:57
  • @Seamus: It most likely would, but then I'd have to figure out what the default spacing actually and then modify that. That's what I'm trying to avoid. In the end, it may be what I have to do.
    – TH.
    Commented Feb 9, 2011 at 11:07
  • The last page of titlesec manual gives you the defaults...
    – Seamus
    Commented Feb 9, 2011 at 11:36

1 Answer 1

4

Looking into titlesec.sty, the following code lines seem to define a "building block" for the spacing before and after headings (the actual spacing is determined by applying a multiplier):

\newskip\beforetitleunit
\beforetitleunit=1ex\@plus.3ex\@minus.06ex
\newskip\aftertitleunit
\aftertitleunit=1ex\@plus.1ex

So try to double the stretchability before headings by adding the following to your preamble:

\makeatletter
\beforetitleunit=1ex\@plus.6ex\@minus.12ex
\makeatother

EDIT: It seems that one must add \titlespacing in order to implement the changes to \beforetitleunit. The following should work and produce "compact" spacing with double stretchability:

\documentclass{article}
\usepackage[compact]{titlesec}
\makeatletter
\beforetitleunit=1ex\@plus.6ex\@minus.12ex
\makeatother
\titlespacing*{\section}{0pt}{*1}{*1}
\usepackage{lipsum}
\begin{document}
\section{A}
\lipsum[1]
\section{B}
\lipsum[1]
\subsection{Ba}
\lipsum[1]
\end{document}
1
  • I wasn't able to get any change by changing that value. See my edit where I added a ridiculous \beforetitleunit value to no effect.
    – TH.
    Commented Feb 9, 2011 at 10:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .