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.

As you can see in the image, the vertical spacing is inconsistent.

enter image description here

I would like to avoid hacking my way into simulating the spacing that multicol uses.

If I use \multicols{1}, I get the warning:

Package multicol Warning: Using `1' columns doesn't seem a good idea. I therefore use two columns instead on input line 20.

What is a good way to get symmetric vertical spacing in this example?

\documentclass{article}
\usepackage{multicol,times}

\begin{document}

\hrule
\begin{multicols}{3}
    \centering {\bfseries Title 1} \\
    \centering Description 1 \\
\columnbreak
    \centering {\bfseries Title 2} \\
    \centering Description 2 \\
\columnbreak
    \centering {\bfseries Title 3} \\
    \centering Description 3
\end{multicols}
\hrule
% \begin{multicols}{1}
    \centering {\bfseries Title 4} \\
    \centering Description 4
% \end{multicols}
\hrule
\begin{multicols}{2}
    \centering {\bfseries Title 5} \\
    \centering Description 5 \\
\columnbreak
    \centering {\bfseries Title 6} \\
    \centering Description 5
\end{multicols}
\hrule

\end{document}
share|improve this question
    
The assumption is that you're generating a much larger (multi-page) document and you're just testing the heading spacing, right? Otherwise a tabular would be fine for presenting the information listed in your example. –  Werner Aug 13 '12 at 16:47
    
You are suggesting to use tabular instead of multicols, not instead of (sub)sections. Is that right? –  Calaf Aug 13 '12 at 16:50
    
Yes, but I'm not sure about the bigger picture for your document. What content will be used between the headings? For example, your three-column Title 1, Title 2 and Title 3: will there be three-column text below that that should break across the page boundary? Another alternative would be to use a 3-column multicol for your single centred Title 4, leaving some empty content in column 1 with a `\columnbreak. –  Werner Aug 13 '12 at 16:52
    
Say there is no big picture. How would you modify the code I provided so that the vertical spacing is consistent? –  Calaf Aug 13 '12 at 16:54
    
I have now simplified the question by removing memoir, replacing sections with hrules, and adding an image. –  Calaf Aug 13 '12 at 17:08
show 1 more comment

1 Answer

up vote 2 down vote accepted

The following provides a consistent spacing - you have to make to use the same code for vertical spacing:

enter image description here

\documentclass{article}
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\newcolumntype{Y}{>{\centering\arraybackslash}X}

%----------
% Sections
%----------
\newcommand{\mysec}[2][2]{%
  \LARGE\noindent\begin{tabularx}{\textwidth}{*{#1}{Y}}
    #2
  \end{tabularx}%
  \bigskip
}

\newcommand{\mysubsec}[2][3]{
  \Large\noindent\begin{tabularx}{\textwidth}{*{#1}{Y}}
    #2
  \end{tabularx}%
  \medskip
}

\newcommand{\mysubsubsec}[2][4]{
  \small\noindent\begin{tabularx}{\textwidth}{*{#1}{Y}}
    #2
  \end{tabularx}%
  \smallskip
}

\begin{document}

\mysec{\bfseries Heading}

\mysubsec{\bfseries Subheading 1}

\mysubsubsec[3]{%
  {\bfseries Title 1} \par Description 1 &
  {\bfseries Title 2} \par Description 2 &
  {\bfseries Title 3} \par Description 3
}

\mysubsec{\bfseries Subheading 2}

\mysubsubsec{%
  {\bfseries Title 4} \par Description 4
}

\mysubsec{\bfseries Subheading 3}

\mysubsubsec[2]{%
  {\bfseries Title 5} \par Description 5 &
  {\bfseries Title 6} \par Description 6
}

\end{document}​

I've used a full-width tabularx which puts a number of Y-columns (defined as centred X-columns). \mysec is followed by \bigskip, \mysubsec by \medskip and \mysubsubsec by \smallskip. This provides some form of consistency. You could use the same for all.


If you want to stick to multicol, using a 3-column layout for the 1-column usage is also possible:

enter image description here

\documentclass{article}
\usepackage{multicol}% http://ctan.org/pkg/multicol

\begin{document}

\noindent\hrulefill\smallskip
\begin{multicols}{3}
  \centering {\bfseries Title 1} \par
  Description 1 \par
  \columnbreak
  {\bfseries Title 2} \par
  Description 2 \par
  \columnbreak
  {\bfseries Title 3} \par
  Description 3
\end{multicols}
\smallskip\noindent\hrulefill\smallskip
\begin{multicols}{3}
  \mbox{} \par \mbox{} \par
  \columnbreak
  \centering {\bfseries Title 4} \par
  Description 4
\end{multicols}
\smallskip\noindent\hrulefill\smallskip
\begin{multicols}{2}
  \centering {\bfseries Title 5} \par
  Description 5 \par
  \columnbreak
  {\bfseries Title 6} \par
  Description 5
\end{multicols}
\smallskip\noindent\hrulefill

\end{document}​
share|improve this answer
    
Very nice. So the answer is that it can't really be done. Either use the minor hack of using \multicols{3} with an empty first column, or instead switch to tabularx. I still label it as a hack, albeit a minor one, because it is no longer possible for the middle column to use more than one third of the width. This is not an issue in my case, so I am happy with that. –  Calaf Aug 13 '12 at 17:43
    
@Calaf: Sometimes, "fooling TeX" is the easiest. But this depends on your application. You can, of course, write your own environments and/or macros, if that seems like less of a hack to you. –  Werner Aug 13 '12 at 17:48
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.