10

I'm using the multicol package and would like to align the baseline of the two columns. The simple use of a \paragraph heading seems to throw off the alignment, which can be pretty jarring visually. Is there any way to force the two columns to stay aligned with one another?

For example, the following produces a document with two columns, which look nice except that the \paragraph headers on the right column aren't aligned with the text on the left:

\documentclass{article}

\usepackage{multicol}
\usepackage{lipsum}

\begin{document}

\begin{multicols}{2}
\paragraph{foo} \lipsum[1-2]
\paragraph{bar} \lipsum[4]
\paragraph{morebar} \lipsum[4]
\paragraph{baz} \lipsum[7-10]
\end{multicols}

\end{document}

Resulting in this:

mis-aligned columns

(I'd like the "morebar" to align with "Mau-" or "rhoncus".)

3 Answers 3

7

You may want to look into using the grid package, which helps achieve at least some of the objectives you're pursuing. Note that you'll probably need to set the lines per page by hand (the package's default is 40). In my experience, it helps to load the microtype package as well when using the grid package.

For more on typesetting with LaTeX on a "grid system," see the question Grid System in LaTeX and the associated answers.

Addendum: In case your objective is more modest than achieving a grid typesetting "look" for your document, for the case you describe you could simply redefine the \paragraph command to leave a fixed amount of whitespace, expressed in multiples of \baselineskip, above each "paragraph" header. For instance, the following code snippet (to be inserted in the document's preamble) instructs LaTeX to leave whitespace in the amount of 2 blank lines above a new "paragraph" header.

\makeatletter
\renewcommand\paragraph{%
    \@startsection{paragraph}{4}{\z@}%
       {2\baselineskip}%  default is "3.25ex \@plus1ex \@minus.2ex"
       {-1em}{\normalfont\normalsize\bfseries}}
\makeatother
1
  • Okay, thanks, sounds like this is pretty complicated in latex. The grid system isn't working for me, but changing the definition of \paragraph to a simple 1x or 2x baselineskip looks good.
    – Noah
    Commented Apr 23, 2012 at 15:04
7

Renew the paragraph definition to be a multiple of baselineskip and things will line up.

\documentclass{article}
\usepackage{multicol}
\usepackage{lipsum}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {\the\baselineskip \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                     {\normalfont\normalsize\bfseries}}
\makeatother
\begin{document}
\begin{multicols*}{2}
\paragraph{foo} \lipsum[1-2]
\paragraph{bar} \lipsum[4]
\paragraph{morebar} \lipsum[4]
\paragraph{baz} \lipsum[7-10]
\end{multicols*}
\end{document}

In the standard classes the aboveskip space is 3.25ex where you need it to be a multiple of baselineskip, as shown in the MWE above. The example will work well both with the starred version and the normal version of the environment.

You need to do this also for any other items you insert such as images, other sectioning commands and the like.

3
  • This looks good on a test document but I think it still allows fractional spacing.
    – Noah
    Commented Apr 23, 2012 at 15:05
  • @Noah Where does it allow fractional spacing?
    – yannisl
    Commented Apr 23, 2012 at 15:55
  • I'm not sure exactly, but using the version Mico posted works, but yours only sometimes does. Doesn't \@plus1ex \@minus.2ex allow it to change if it feels like it?
    – Noah
    Commented Apr 23, 2012 at 16:54
0

If I have understood your question, you should put \raggedcolumns right after \begin{multicols}{2}.

1
  • 1
    It's the \paragraph command that seems to be the offender -- \raggedcolumns just makes the bottoms of the columns vary in position, but it doesn't remove the variable spacing on the \paragraph command.
    – Noah
    Commented Apr 23, 2012 at 14:43

You must log in to answer this question.

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