Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using titlesec in a two column environment, and sometimes my sections start on a new page or the second column, and leave blocks of white space at the bottom of the previous page/column.

I am wrapping the text around my section number, and formatting the section number to be the height of 2 lines. I would like to tell Latex that it's ok to put the start of the section at the bottom of the page if there is room for two line-heights.

Here is a relevant example. The second section starts in the second column, and I would like it to start at the bottom of the first.

\documentclass[10pt,twocolumn,twoside,openany]{book}
\usepackage[margin=.5in, paperwidth=6in, paperheight=9in]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[block]{\fontfamily{phv}\Huge\filcenter\selectfont}{\thechapter}{0em}{\MakeUppercase}
\titlespacing{\chapter}{0pc}{0ex plus .1ex minus .1ex}{2pc}
\titleformat{\section}[wrap]{\fontfamily{ptm}\fontsize{24}{32}\selectfont}{\thesection.}{5pt}{\vskip-0.5em}
\titlespacing{\section}{6pt}{-2ex plus .1ex minus .1ex}{6pt}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{1}
\renewcommand{\thechapter}{}
\renewcommand{\chaptername}{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\begin{document}
\chapter{New Chapter}
\section{1} HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
HERE IS SOME TEXT THAT DOESN'T TAKE UP THE WHOLE COLUMN.\newline
\section{2} HERE IS SOME MORE TEXT THAT SHOULD START AT THE\newline BOTTOM OF FIRST COLUMN.
HERE IS SOME MORE TEXT IN THE SECOND SECTION. THIS CAN WRAP TO SECOND COLUMN IF NECESSARY.\newline
HERE IS SOME MORE TEXT IN THE SECOND SECTION. THIS CAN WRAP TO SECOND COLUMN IF NECESSARY.\newline
HERE IS SOME MORE TEXT IN THE SECOND SECTION. THIS CAN WRAP TO SECOND COLUMN IF NECESSARY.\newline
HERE IS SOME MORE TEXT IN THE SECOND SECTION. THIS CAN WRAP TO SECOND COLUMN IF NECESSARY.\newline
\end{document}
share|improve this question
add comment

2 Answers 2

  • The spacing of the section heading determines, how much space is required. Reduce the spacing if is should fit to the column at all.

  • You can tell LaTeX how much space should be reserved. If there's insufficient space left, it breaks the page or column, respectively. The needspace package is a good tool for that. Load it by

    \usepackage{needspace}
    

    and before the section heading write

    \needspace{2\baselineskip}
    

    or choose any other meaningful length. The package provides another command \Needspace which is exact but less efficient. A starred version \Needspace* works flush bottom instead of ragged bottom, which is the default behavior.

share|improve this answer
    
I'm still thinking that my issue is occurring because of a titlesec setting that prevents latex from separating a title from the text under it. I notice that adjusting the vertical space before the title forces the 2nd section back to the first column, but with overlapping text on the 1st section: For example: \titlespacing{\section}{6pt}{0pt}{6pt} Section 2 will be on second column \titlespacing{\section}{6pt}{-40pt}{6pt} Section 2 will be on second column \titlespacing{\section}{6pt}{-45pt}{6pt} Section 2 will be on first column, but overlap the text of Section 1 –  Rando Jun 1 '11 at 21:11
add comment

After a lot of troubleshooting, I found that my spacing issues were caused by the size of the font I used in the section:

\titleformat{\section}[wrap]{\fontfamily{ptm}\fontsize{24}{32}\selectfont}{\thesection.}{5pt}{\vskip-0.5em}

I found that I could control the spacing when I made the font smaller, like in this example:

\titleformat{\section}[wrap]{\fontfamily{ptm}\small\selectfont}{\thesection.}{5pt}{\vskip-0.5em}

But I need a bigger font, and when the font got too big, the spacing became an issue. I tried just putting a big font in my section like this, which appeared to work until I started displaying the section numbers in the document header. so this was a bad idea:

\section{\fontfamily{ptm}\fontsize{24}{32}\selectfont1} ... \section{\fontfamily{ptm}\fontsize{24}{32}\selectfont2} ... \section{\fontfamily{ptm}\fontsize{24}{32}\selectfont3}

What worked for me

Just moving my font stuff in the declaration gave me the results I wanted. A large font, and the ability to control the spacing like I should be able to:

\titleformat{\section}[wrap]{}{\thesection.}{.5em}{\vskip-1em\fontfamily{ptm}\fontsize{24}{24}\selectfont}

I moved the font stuff from the <format> section to the <before> section. For some reason, declaring the large font size behaved better for me there.

\titleformat{<command>}[<shape>]{<format>}{<label>}{<sep>}{<before>}[<after>]

Where <format> is applied to the whole title—label and text, and <before> is for code preceding the title body.

Now the spacing stuff in titlesec works like I would expect it to (I adjusted this in my final result):

\titlespacing{\section}{6pt}{-2ex plus .1ex minus .1ex}{6pt}

And if I need to adjust the spacing, I just change the {-2ex plus .1ex minus .1ex} part.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.