LaTeX two column layouts and rubber lengths

Today I gave my advisor the draft of the final chapter of my dissertation, which I have been working on fervently for the last week or so. I decided that I deserved a little break before getting back to the grindstone of implementing comments from my advisor. I decided to spend some time working on the two column layout of my dissertation.

Two columns! You may be thinking that I am crazy. Certainly my institution wouldn’t allow me to use a two column layout for my dissertation! That is indeed correct. The requirements set by the University of Michigan produce a pretty ugly document — one-sided, double-spaced (or 1.5), and running headers aren’t allowed. They actually don’t specify if you can use two columns or not, but I didn’t even bother asking, because I am pretty certain the answer is no. Now, just because the official copy that I hand in has to look boring doesn’t mean that I can’t make a nice copy for myself, and for other people I give a copy, like the members of my committee. And with LaTeX, that is relatively easy to do.

original format two column format
one column layout one column layout

Many scholarly journals, especially scientific journals use a two column layout. There are good reasons for this. When reading text, one of the most difficult tasks is to move down a line. Most languages of the world (but not all) are read either right to left or left to right, which means that moving down a line means moving your eyes all the way across the width of the text. As the width of a text gets wider, so does this task. For this reason, many books use relatively small paper. A common novel usually has paper sized about 6in x 8in. This is fine for books which are professionally printed, but the printing of a dissertation is usually restricted to standard 8.5 x 11 inch paper. Having a one column format (with reasonable margins of 0.5 to 1 inch) on 8.5 x 11 inch paper is very hard to read. A two column layout is much easier for readers.

For the most part, making a two column layout in LaTeX is extremely easy. Simply specify twocolumn in the document class definition:

\documentclass[letterpaper, twosided, twocolumn]{book}

However, one quickly notices that some things need adjusting. First off, equations, figures, and tables which are too wide to fit in one column need to be specified as double column width. For figures and tables, simply use table* and figure* environments. Equations can be a bit trickier, but luckily I didn’t have any really long equations. In addition, using table* in a one-column document doesn’t have any effect, which makes it very easy to switch back and forth between one and two column layouts. (Note that LaTeX only allows two-column floats at the top of the page by default, though some different class files, such as JASAtex, get around this somehow).

Some of the main jobs of LaTeX are:

  1. format text into fully justified paragraphs, hyphenating when necessary
  2. Break pages at appropriate places (i.e. don’t start a new section at the bottom of a page, or leave one line stranded on an otherwise blank page
  3. place tables and figures in appropriate positions

In a two column layout, all of these jobs get a little trickier. LaTeX uses several parameters which controls the behavior of the processes that handle these jobs. LaTeX realizes that hyphenating words at line breaks should be avoided if possible, but sometimes it is necessary in order to have justified text which has approximately equal inter-word spacing. In a two column layout, each column usually has fewer characters than in a one column layout, which means that more words will be hyphenated. If you don’t like this, you can increase the \hypenpenalty, which will cause LaTeX to hyphenate fewer words, and instead be a little sloppier about inter-word spacing

% don't hyphenate so much - default = 200, max (never hyphenate) = 10,000
\hyphenpenalty=800

You may also wish to alter float placement a bit. By default, LaTeX puts figures and tables on their own page if they take up more than 70% of a page, and says that float pages should be at least 70% full of floats. I would prefer to squeeze a bit more onto a page, so I increase these values a bit:

%two column float page must be 90% full
\renewcommand\dblfloatpagefraction{.90}
%two column top float can cover up to 80% of page
\renewcommand\dbltopfraction{.80}
%float page must be 90% full
\renewcommand\floatpagefraction{.90}
%top float can cover up to 80% of page
\renewcommand\topfraction{.80}
%bottom float can cover up to 80% of page
\renewcommand\bottomfraction{.80}
%at least 10% of a normal page must contain text
\renewcommand\textfraction{.1}

There are a few more parameters which you can tweak to save a little space. Now that we have big floats on a page, we might need to make a little more room for text, so we can decrease the textfloatsep from the default value of 20pt

%separation between floats and text
\setlength\dbltextfloatsep{9pt plus 5pt minus 3pt }
%separation between two column floats and text
\setlength\textfloatsep{10pt plus 4pt minus 3pt}

Now those rubber lengths. Notice that the above lengths include plus and minus. What this says is that the dbltextfloatsep should be 9pt, but can be anywhere between 6pt and 14pt. Rubber lengths allow LaTeX to adjust spacing (in this case vertical spacing), to make better page breaks. Looking at the code from the standard book.cls, we will also find rubber lengths in the definition of sectioning commands, e.g.:

\newcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries}}

While I still have yet to find exactly what all this means, I am pretty sure that the two middle lines specify how much space should come before and after the section heading. This says that there should be between -4.5ex and -3.3ex before the heading, and 2.3ex to 2.5ex after the heading, before the beginning of the section text. It also says that the font of the heading should be Large and bold. While this looks quite nice by default, I found the spacing too large for a two column layout, so I redefined some of these commands:

\renewcommand\section{\@startsection {section}{1}{\z@}%
{-1.5ex \@plus -.5ex \@minus -.8ex}%
{1.5ex \@plus.2ex \@minus .2ex}%
{\raggedright\normalfont\large\bfseries\sffamily}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-1ex\@plus -.4ex \@minus -.4ex}%
{1ex \@plus .2ex \@minus .2ex}%
{\raggedright\normalfont\bfseries\sffamily}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{2ex \@plus1ex \@minus.3ex}%
{-1em}%
{\normalfont\normalsize\bfseries\sffamily}}

Notice that for subsubsection, the lengths seem to be reversed, in that the first length is positive, and the second is negative. This has the effect that the heading is placed on the same line as the text, instead of on a separate line. Paragraphs and subparagraphs are formatted like this, but I wanted it for subsubsection, which is the lowest level of sectioning I use in my dissertation.

I made one additional modification to all these parameters. The default space between columns seems to be about .1in, which is not very much. I increased this to .25in.

\setlength{\columnsep}{.25in}

With just a little tweaking, I turned the default formatting into a very professional looking document.

Addendum — equations

Several people have asked about how to handle long equations. There is no great way, and it will depend on your equation. If you absolutely need the whole page, you have to put the equation in a figure* or table* environment, which means that it can only appear at the top of a page. Other options are to split the equation up into multiple lines, make the font a bit smaller, or go into the margins a bit. I used all of these techniques for one equation in my dissertation. Here is the code:


\hspace*{-.4em}%
\begin{minipage}{1.02\columnwidth}
{\fontsize{8.7}{10}\selectfont
\begin{multline}%
\label{E:NPR}
p(ID)=\\
\frac{\displaystyle\prod_{i=1}^{n} p(PS_i|PS_i)\cdot Freq_S}
{\left\{\left[\displaystyle\prod_{i=1}^{n} p(PS_i|PS_i)\right]\cdot
Freq_S\right\} +
\displaystyle\sum_{j=1}^{nn} \left\{\left[\displaystyle\prod_{i=1}^{n}
p(PN_{ij}|PS_i)\right]\cdot Freq_{Nj}\right\}
}
\end{multline}%
}
\end{minipage}

And the resulting output.

screenshot of a long equation

screenshot of a long equation that uses the margins a bit, has smaller font, and uses multiple lines

It is not perfect, but I am pretty happy with the results.

Join 165 other subscribers

archives

  • 2024 (10)
  • 2023 (8)
  • 2022 (15)
  • 2021 (19)
  • 2020 (1)
  • 2019 (1)
  • 2018 (2)
  • 2017 (1)
  • 2016 (2)
  • 2015 (5)
  • 2014 (5)
  • 2013 (2)
  • 2011 (7)
  • 2010 (10)
  • 2009 (50)
  • 2008 (28)
  • 2007 (31)
  • 2006 (8)

Category