# Problem with multicols environment layout

I've a little problem with multicols. This is my MWE:

%%!TEX TS-program = latex
\documentclass[a4paper,11pt]{article}
\usepackage[frenchb]{babel}
\usepackage{multicol}

\usepackage[a4paper, dvips, left=1.5cm, right=1.5cm, top=2cm,%
bottom=2cm, marginpar=5mm, marginparsep=5pt]{geometry}

\begin{document}

\setlength{\columnseprule}{0.5pt}
\begin{multicols}{4}\noindent
\begin{enumerate}
\item $2 \times 4 = \ldots\ldots$
\item $45 \div 5 = \ldots\ldots$
\item $4 + 10 = \ldots\ldots$
\item $10 \times 10 = \ldots\ldots$
\item $\ldots\ldots - 3 = 6$
\end{enumerate}
\end{multicols}
\end{document}


This produces calculations in only the first 3 columns, but I want the four columns filled with one calculation before putting a second one in the first column...

How can I do that?

-
Welcome to TeX.sx! The columns are filled first top to bottom, then left to right. Maybe you want first left to right, then top to bottom instead? –  Stephan Lehmke Dec 13 '12 at 22:34
Check the documentation of multicol, section 2.1. –  Martin Schröder Dec 13 '12 at 22:36
@MartinSchröder which bit of that section exactly? –  David Carlisle Dec 13 '12 at 23:11
@DavidCarlisle: Don't know. The question is: Can you twiddle the parameters so that the columns are automatically balanced? But probably only Frank knows it :-). –  Martin Schröder Dec 14 '12 at 7:23
@MartinSchröder I couldn't (see my answer:-) –  David Carlisle Dec 14 '12 at 9:22

I needed to force the breaks:

\documentclass[a4paper,11pt]{article}
\usepackage[frenchb]{babel}
\usepackage{multicol}

\usepackage[a4paper, dvips, left=1.5cm, right=1.5cm, top=2cm,%
bottom=2cm, marginpar=5mm, marginparsep=5pt]{geometry}

\begin{document}

\setlength{\columnseprule}{0.5pt}
\begin{multicols}{4}\raggedcolumns
\begin{enumerate}
\item $2 \times 4 = \ldots\ldots$
\item $45 \div 5 = \ldots\ldots$
\item $4 + 10 = \ldots\ldots$
\columnbreak
\item $10 \times 10 = \ldots\ldots$
\columnbreak
\item $\ldots\ldots - 3 = 6$
\end{enumerate}
\end{multicols}
\end{document}

-
Thx for your quick response ! In reality, i think this wont help me : My real problem is that kind of file is generated by a python program. There is a tex template, and the program user can ask 2, 5, 10, or 100 maths expressions... So i dont want to make a lot of elsif and columbreak for each number of expressions :? Is there a beautiful solution ? Perhaps i should post the python generating routine (very simple...)and the tex template... –  culturoeil Dec 14 '12 at 23:29
well i don't know python that well but I suspect it is easier to add a forced column break every n entries in python than in tex. Of course if you are forcing the breaks you don't really need multicols at all. Alternatively if you numbered across rather than down it would be trivial as that is the normal paragraph flow –  David Carlisle Dec 14 '12 at 23:46

The simple answer is: no you can't customize the multicols balancing algorithm in a way that it automatically generates balancing that matches your use case.

The balancing approach of multicols is based on the assumption that we are balancing text that is read column by column from left to right and that any excess space it placed in the rightmost column if balancing isn't able to find a split that keeps all columns in equal length. As your MWE requires that the first column holds 2 lines (minimum) the algorithm therefore generates 2 lines for the remaining columns too and that makes the last column empty.

In your example with just formulas (that may be read more from left to right rather than top down) this may not look so good. But for normal text (and that is what multicol is intended to managed) you formatting as 2+1+1+1 is inferior to 2+2+1+0.

But truth is that very short columns do not work well in either case with text and typically require manual interventions and decisions. At the moment multicol balances happily down to a single line, e.g., 1+1+1+1. But for many text applications it may even be better to force a (customizable) minimum of 2 or 3 lines even if that means some columns stay empty.

[Side remark: I see that the equations are numbered, but I would not be surprised if most people would read this left to right and then surprised by equation 1. followed by equation 3. have to rescan. Don't think that this is a very effective way of presentation. So maybe this format should be replaced by a more a horizontally oriented approach (via longtable or the like).]

-