3

With the following code:

\documentclass[a4paper]{report}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\noindent Vediamo un po' di testo a due colonne. Proviamo a cambiar colonna: \columnbreak
\texttt{\textbackslash columnbreak} serve a passare alla colonna successiva, ossia ad inserire un \emph{Column Break}, un'interruzione di colonna, come direbbe Word.
\end{multicols}
\end{document}

I should get a two-column bit of text with one column containing the text up till colonna: and the other one contanining the rest. Trouble is, I'm pretty far from that:

enter image description here

Adding \\ before \columnbreak or substituting \columnbreak with a negative \penalty simply doesn't work either. So what do I do to get from \texttt{\textbackslash columnbreak} on onto column 2? And why is \columnbreak being thus totally ignored?

lockstep
  • 250,273
MickG
  • 5,426

2 Answers2

7

\columnbreak like \vspace and \pagebreak etc if used in horizontal mode inserts itself into a \vadjust node that TeX's paragraph breaker will insert after the current line of text is broken into lines. Only once the \vadjust node contents are interpreted in vertical mode will the underlying penalty affect the column breaking.

In this case the node (just) gets put into the line with your \columnbreak text so has an effect after that line, it is easier to see with more text that id does force a break:

enter image description here

\documentclass[a4paper]{report}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\noindent Vediamo un po' di testo a due colonne. Proviamo a cambiar colonna: \columnbreak
\texttt{\textbackslash columnbreak} serve a passare alla colonna successiva, ossia ad inserire un \emph{Column Break}, un'interruzione di colonna, come direbbe Word.

zzz

zzz

\end{multicols}
\end{document}
David Carlisle
  • 757,742
6

This example shows that \columnbreak is obeyed:

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\noindent Vediamo un po' di testo a due colonne. Proviamo a cambiar colonna: \columnbreak
\texttt{\textbackslash columnbreak} serve a passare alla colonna successiva, ossia a
inserire un \emph{Column Break}, un'interruzione di colonna, come in altri programmi
di scrittura. Chissà che succede ora qui avendo aggiunto testo.
\end{multicols}
\end{document}

enter image description here

Let's try without the italian option and fontenc, so that the output should be similar to yours

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\noindent Vediamo un po' di testo a due colonne. Proviamo a cambiar colonna: \columnbreak
\texttt{\textbackslash columnbreak} serve a passare alla colonna successiva, ossia a
inserire un \emph{Column Break}, un'interruzione di colonna, come in altri programmi
di scrittura. Chissà che succede ora qui avendo aggiunto testo.
\end{multicols}
\end{document}

enter image description here

When \columnbreak appears inside a paragraph, the corresponding penalty is inserted after the line where \columnbreak happens to fall. In both cases it falls in the line containing \texttt{\textbackslash columnbreak}. Changing the input to be

\noindent Vediamo un po' di testo a due colonne. Proviamo a cambiar colonna:\columnbreak
\ \texttt{\textbackslash columnbreak} serve a passare alla colonna successiva, ossia a
inserire un \emph{Column Break}, un'interruzione di colonna, come in altri programmi
di scrittura. Chissà che succede ora qui avendo aggiunto testo.

the penalty is attached to the colon, instead of the backslash and indeed the output is

enter image description here

If you want to add a column break exactly after the colon, though, you should do

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{multicol}

\begin{document}
\begin{multicols}{2}
\noindent Vediamo un po' di testo a due colonne. Proviamo a 
cambiar colonna:\columnbreak\linebreak
\verb|\columnbreak| serve a passare alla colonna successiva, ossia a
inserire un \emph{Column Break}, un'interruzione di colonna, come in altri programmi
di scrittura. Chissà che succede ora qui avendo aggiunto testo.
\end{multicols}
\end{document}

enter image description here

egreg
  • 1,121,712