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 |
|---|---|
|
|
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:
- format text into fully justified paragraphs, hyphenating when necessary
- 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
- 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.
It is not perfect, but I am pretty happy with the results.



55 responses to “LaTeX two column layouts and rubber lengths”
Rob, you’re hot in latex.
Thanks for the great work! It really is more than what was expected. I loved its simplicity! Keep up the good work!
I think you have a typo in your columnsep code above: \setlength{columnsep}{.25in} should be \setlength{\columnsep}{.25in}
Notice the \ preceding columnsep.
I found your article very useful–thanks for posting it! I also see you use powerdot. I do as well and I like it a lot.
Wade: Thanks for your comment. I have corrected the code.
Rob
Really impressive. I am a LaTeX newbie and I must admit I was not aware of the ‘table*’ and ‘figure*’ environments; hence, to achieve page-wide tables or figures with ‘twocolumn’ style I used the environmente ‘strip’ from package ‘cuted’ (with the drawback that no references toward the environment are allowed).
So, a big thank you :)
I’m just preparing a paper for an international conference and wasn’t aware of the figure* environment until I read your blog.
Thanks a lot!
Hi,
I got a question: if I add the
\renewcommand\section{\@startsection {section}{1}{\z@}% {-1.5ex \@plus -.5ex \@minus -.8ex}% {1.5ex \@plus.2ex \@minus .2ex}% {\raggedright\normalfont\large\bfseries\sffamily}}
in my Settings.tex file, LaTeX is complaining that I cannot use \spacefactor in the vertical mode. What is wrong?
Thanks,
Chris
Chris,
I would have to see a minimal example to be sure, but if you are inputing Settings.tex just as a normal file like:
\input{Settings}
then you must make sure to start Settings.tex with
\makeatletter
and end with
\makeatother
Commands with the @ symbol in them are not really intended to be modified by the average user, only true TeXnicians, and is kind of intended to protect the average user from messing things up too much. The makeatletter is not necessary in .sty files.
I hope this helps.
Rob
Hi there, very impressive tweaking! I am preparing a document which is best suited for twocolumn but I was wondering if there is a way to have a line breaking the two columns. I am unlikely to have images that need to span the two columns so hopefully that should be ok. Also is there a way to have two columns on most pages but some that are one column pages?
Thank you for making this website
Ben
Ben,
Glad you found the info helpful. There is a way to have a line breaking the two columns. Simply do:
\setlength{\columnseprule}{XXpt} — 1-2pt is probably a good thickness for the line.
It is also possible to switch back and forth from 1 to 2 columns. If you are doing this frequently , you may want to check out the multicol package. It makes doing this very easy. If you are only doing it occasionally, you can do something like the following:
\makeatletter
\twocolumn[%
\begin{@twocolumnfalse}
blah blah
\end{@twocolumnfalse}
]
\makeatother
(thanks to Kevin McGowan for that tip)
This will make a section span both columns without inserting a page break. If you want a pagebreak, you can simply do:
\onecolumn
starts a new page with one column
blah blah
\twocolumn
new page with two columns
Also, to force page breaks, use
\clearpage
when in single column mode, or
\cleardoublepage
when in two column mode
Hope that helps.
Rob
I just wanted to say thanks for the very speedy reply! It means I can get more done on it tonight.
Thank you again, it’s much appreciated
Ben
Is there any possibility to introduce different parameters of \columnsep in the same twocolumn text? I’ve tried to change it with \newcommand{…}{\twocolumn\setlength{\columnsep}{…}} but with no results. Help me!
Piotr
I tried the following code segment:
\makeatletter
\twocolumn[%
\begin{@twocolumnfalse}
blah blah
\end{@twocolumnfalse}
]
\makeatother
I wanted to put a table between the tags \begin{@twocolumnfalse}
and \end{@twocolumnfalse}. It did not work. Any way to solve this problem?
I want single column to contain the wide table with changing to a page. Can this be done?
Thanks!
Xiongfei:
\begin{table*}
\centering
\caption{full width table. Note that it can only appear at the top of a page. That is ok. Most journals do this anyways}
\begin{tabular}{l r}
\hline
full & width\\
easy & simple\\
\hline
\end{tabular}
\end{table*}
If you really need it in the middle of the page, you could use the \twocolumn command, but you cannot put a float inside of it (tables and figures are floats — latex decides where to place them, not you). You should be able to use a tabular environment inside the \twocolumn environment. (haven’t tested it though)
[…] sense that LATEX tried to make use of all available space, it often looked odd. Today I came across this article, which talks about an attempt to create a two column […]
Thanks a lot for this nice work. It is good to see this dedication to increasing understanding. Well done!
Stephane
Thats a nice work. It worked for me. But right now i am interested solve a new problem. Can i switch on and switch off @twosidetrue and @twoside false to go to odd pages in the running text. I tried it but did not work for me. Can you please help me.
Very useful article, thank you!
I have been writing a document that has two-column and I have a really long equation. I want to specify this equation as double column width. How can I do this?
Ali,
If you can try to break up the equation into multiple lines using eqnarray or multiline. Otherwise, you must put the equation in a figure* or table* environment, which means that it can only appear at the top of the page. You could also try altering the font size a bit to squeeze it in, or sticking out into the margins a little bit. For one equation in my dissertation I ended up using several strategies, including sticking into the margin, breaking up the equation, and making the font size smaller. I have added the code to the end of this post, along with a screenshot of the result.
From the aps website:
% If in two-column mode, this environment will change to single-column
% format so that long equations can be displayed. Use
% sparingly.
%\begin{widetext}
% put long equation here
%\end{widetext}
I tried it, it works (using revtex4).
I have a two column document and I need to include a big table in it. But I want it on the bottom of the page not on the top of it, have any idea?
Thanks,
Amir.
Thanks for the help with two columns, especially the column separation command, which I couldn’t find til now, \setlength{\columnsep}{.25in}
Thanks dude!
Many thanks, it help me out in two volume problem with long table.
Hi, this is the second time I find a solution for my problem (1st related to twocolumn -> onecolumn switching of tables & 2nd related to eqn scaling). Thanks a lot.
Thank you for your good work. It is brief and to the point. The project report like and goal-driven style helps me every single word. Moreover, it is not boring to keep on the reading. Genius!
Congrats on a job well-done! Great output and clearly a lot of work put into it.
Really strong work. Succint and informative all at once.
Hi There
I am totally new, and will appreciate a sample latex code to tell me how to put the figure on both columns as mentioned above.
Regards
@Ran
\begin{figure*}
\includegraphics{yourGraphicsFile}
\end{figure*}
I am using the \ctable package, and would like to place two tables side by side without using the \twocolumn option – ideally the \multicol package may be useful, but doesn’t work, does anyone know how to do this?
I am using the \ctable package, and would like to place two tables side by side without using the \twocolumn option – ideally the \multicol package may be useful, but doesn’t work, does anyone know how to do this?
I need to place two tables side by side, and am using the \ctable command to create the tables (better footnote layout). I cannot use the \twoocolumn option because of the empty space created. I have tried using the multicol package, but the tables are not showing, can anyone help?
@kutlwi,
I think that the subfigure package can do this. The other option is to use two minipage environments, like so:
\begin{table}
\begin{minipage}
\begin{tabular}{l r}
data & 0.1\\
\end{tabular}
\end{minipage}%
\begin{minipage}
\begin{tabular}{l r}
data & 0.1\\
\end{tabular}
\end{minipage}
\end{table}
Thank you. the subfigure and minipage environments didn’t work for me, but what worked is the \cleardoublepage command as follows:
\twocolumn
\cleardoublepage
blah blah blah
\setlength{\columnsep}{1cm}
\ctable[
data & etc
}
\ctable[
data & etc
}
Hi,
Impressive site you got here…I’m a LaTEX rookie and wanted to know how you’ve justified the paragraph wrt. both left and right margins.
Thanks.
@Sandip,
Glad you are finding my site useful. Full justification is the default in LaTeX. You shouldn’t have to do anything special.
Rob
just wanted to send out a quick thanks for a lot of good info.
Hi Rob, Wondering if you could help me too.
I need my manuscript to be in single column and double spaced using RevTex4. For this I used:
\documentclass[floatfix,showpacs,preprintnumbers,amsmath,amssymb]{revtex4}
\renewcommand{\baselinestretch}{2}
The problem with this is that on compilation, the dvi and pdf files have margins smaller than 1in. Tried geometry package and ran in to the same troubles fixing which essentially removes all formatting that RevTex4 does. Could you please help me with comments/suggestions?
Thanks,
PG
Pavan,
Doesn’t revtex have a preprint option, which should set double spacing and single column automatically?
Just use preprint in the documentclass definition.
Rob
\documentclass[11pt,floatfix,showpacs,preprintnumbers,english,aps,preprint,amsmath,amssymb]{revtex4}
Hi Rob,
I used the above options and it worked smoothly. Also, the dvitopdf on Kile worked beautifully.
PG
Hi Rob,
Yet another question. In the example you show, the figure is wider than column and the text nicely wraps around it. I would like to get something similar but I ended up with http://www.flickr.com/photos/26055527@N05/3485892171/ . The figure here is wider than the text column and spills on to the text of the adjacent column.
Could you please take a look and help me understand where I went wrong?
Thanks,
PG
Make sure you use the figure* environment
Hi Rob,
Was wondering if you have an ideas on this. I am writing a 2 column paper but have some figures that I want to include in a landscape orientation (they show up too small, even if I make them span 2 columns). How would I go about having landscape figures in such a document \documentclass[twocolumn]{article}
Thanks,
D
To put one word at center of 3 rows, the following command is used:
\multicolumn{3}{*}{John}
But how to put two words in different line at the center of 3 rows? For example, in the following situation, “John” appears in the 1st row and “Stanley” appears in the 2nd row, and 3rd row is empty.
————
John
Stanley
————
I am looking for a latex command that can make the two names appear at the center of the 3 row block in a table.
Please reply.
I couldn�t resist commenting.
I want to have three or four table in one row. what i do? please help me with one example
Hi,
When we write paper in two column fomat the last page usually contains text in either part of first column or second column, i.e the length of text in both column is not equal. Is is possible to make equal length of text in both the columns of last page of the documents?
Biswarup
Biswarup,
As far as I know, this is not possible using the default two column abilities in most of the classes. It is however possible, as I know that JASATeX (the class for the Journal of the Acoustical Society of Amercia) does this. I think it is also possible is use the multicol package. So you could try wrapping your whole document inside a multicols environment, like so:
\documentclass{minimal}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
some text
\end{multicols}
\end{document}