5

This code:

\documentclass{article}

\usepackage{polyglossia}

\usepackage{multicol}
\usepackage{calc}

\setlength{\parindent}{0pt}
\begin{document}

\begin{multicols}{2}
    \begin{center}
       \huge Left
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Left
    }
    \columnbreak
    \begin{center}
        \huge Right
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Right
    }
\end{multicols}

\end{document}

Produces:

http://flyx.org/files/multicols.png

Why is the huge text aligned, but the frameboxes not?

  • Because the right text has one more letter ;-) – Bernard Sep 10 '14 at 15:40
4

You need a blank line before \columnbreak

enter image description here

\documentclass{article}

%\usepackage{polyglossia}

\usepackage{multicol}
\usepackage{calc}

\setlength{\parindent}{0pt}
\begin{document}

\begin{multicols}{2}

    \begin{center}
       \huge Left
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Left
    }

    \columnbreak

    \begin{center}
        \huge Right
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Right
    }
\end{multicols}

\end{document}

An alternative fix that actually points to the underlying cause is to add a % to teh end of the paragraph

\documentclass{article}

%\usepackage{polyglossia}

\usepackage{multicol}
\usepackage{calc}

\setlength{\parindent}{0pt}
\begin{document}

\begin{multicols}{2}

    \begin{center}
       \huge Left
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Left
    }%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    \columnbreak

    \begin{center}
        \huge Right
    \end{center}
    \framebox[.5\textwidth-.5\columnsep]{
        Right
    }
\end{multicols}

\end{document}

Normally the end of line at the end of a paragraph gets converted to a space token but does no harm as TeX's primitive line breaking routine does an \unskip on the horizontal list to remove a final space before breaking in to lines. But here the \vadjust node comes after the space so the space is not removed by \unskip and as the preceding part of the paragraph was already full width (the framebox) the linebreaker made a new line that only contains a space (and \parfillskip glue) so what looks like extra vertical space is in fact a horizontal extra line of the paragraph (that happens to be white). You would see the same with \label{} or \vspace{} or even \mbox{} anything that protects the final space from \unskip.

  • Can you explain why / what happens when I don't have a blank line there? – flyx Sep 10 '14 at 15:40
  • 3
    @flyx it goes wrong:-) I'd need to add \tracingall and stare at it (or get Frank to as it's his code:-) but basically if you don't put the line there the columnbreak command is met in horizontal mode: it is then (like \vspace) delayed in a \vadjust node and re-inserted after the paragraph has finished which (for reasons I didn't trace today) means that the timing of white space being discarded at the top of a column, and the column break happening gets messed up. – David Carlisle Sep 10 '14 at 15:50
  • @flyx answer updated – David Carlisle Sep 11 '14 at 14:59
3

This is actually not an issue of multicol but a general problem with a core functionality of LaTeX. You get exactly the same kind of behavior if you replace \columnbreak by \label{foo} or \index or ...

The issue is that these "invisible" commands internally use \@bsphack...\@esphack to hide themselves and to avoid that you end up with two spaces (on the left and the right). Problem is they keep the space on the left and suppress (if it exists) one at the right.

But because of the invisible command (in case of \columnbreak that is a \vadjust) the space is not removed by the \par command. Thus you end up with a framebox of exactly the width of a line + 1 space (that results in the second line).

If however you first end the paragraph it will be 1 line long.

The general answer is attach "invisible commands to a previous word if they are used in horizontal mode, especially at a paragraph end. (a % for example would do too)

Maybe something can be done about this but I think this would be rather dangerous to change the behavior of \@bsphack and friends.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.