4

I would like to have a forced line break without having a break in a column, similar to how the //* gives a line break while preventing the page from breaking. Specifically, I would like to be able to do this within the multicol environment. Does anyone know how to do this? Here is a MWE.

\documentclass{article}
\usepackage{multicol}
\usepackage[top=5in,bottom=5in,right=.5in,left=.5in]{geometry}

\begin{document}
\begin{multicols}{2}
\noindent
Line 1\\
Line 2\\
I would like to have this line 3 in the same col as line 2\\
Line 4
\end{multicols}
\end{document}

EDIT: This would be used for a "living" document. Basically, I would want to be able to put this "line break" command anywhere that I would want a line break, and have TeX "know" not to break a column where this command falls, but instead, to extend the length of the column further, perhaps even into the margin at the end. Does anyone know how to do this?

6
  • 1
    If you want stuff to stay together, why not just use \parbox{\columnwidth}{\strut ... \\ ... \\ ... \strut}?
    – Werner
    Oct 6, 2013 at 20:50
  • Out of curiosity, what exactly does the \strut command do? Oct 7, 2013 at 2:32
  • Also, please see the edit I just added. Oct 7, 2013 at 2:37
  • The \strut ensures that the height/depth of a line is properly aligned; something that is problematic when you box text. See How to keep a constant \baselineskip when using minipages (or \parboxes)?.
    – Werner
    Oct 7, 2013 at 2:46
  • What is a "living" document and how does that impact how commands are used? Is Werner's suggestion too rigid for "living" documents?
    – jon
    Oct 7, 2013 at 4:38

3 Answers 3

7

I'm a bit surprised by the question as well as by the answers given so far, because the simple answer is: use \\* it will break break the line while preventing a page break at the same point. This works in the same way inside multicol and outside (or rather in the case where it fails in a normal column it will fail in multicol too).

So in the particular example, using \\* will does exactly what is wanted: line 2 and 3 will stay together and this is not broken by the balancing of multicol either.

5

Use \vfill\columnbreak when you want to break.

MWE

\documentclass{article}
\usepackage{multicol}
\usepackage[top=5in,bottom=5in,right=.5in,left=.5in]{geometry}

\begin{document}
\begin{multicols}{2}
\noindent
Line 1\\
Line 2\\
I would like to have this line 3 in the same col as line 2
\vfill\columnbreak
Line 4
\end{multicols}
\end{document} 

Output

enter image description here


Edit

I'm not sure to understand the request in your edited question, but you probably want to have a look at the paracol package.

Here's an example

\documentclass{article}
\usepackage{paracol}
\usepackage[top=5in,bottom=5in,right=.5in,left=.5in]{geometry}

\begin{document}
\begin{paracol}{2}
\noindent
Line 1\\
Line 2\\
Line 3\\
Line 4\\
Line 5\\
Line 6\\
Line 7\\
Line 8
\switchcolumn
Line 9
\end{paracol}
\end{document} 

Until you issue the command \switchcolumn your lines will be indefinitely in the first column.

2
  • I would like to have it so that there is a line break no matter what, but does not have a column break if such a break would occur. Because I would be using this code for a "living" document, I'm looking for something a little more flexible than this :/ Oct 7, 2013 at 2:35
  • @AbeSchulte See if the edit can help you. Oct 7, 2013 at 5:53
2

use the star version:

\begin{multicols*}{2}
\noindent
Line 1\\
Line 2\\
I would like to have this line 3 in the same col as line 2\\
Line 4
\end{multicols*}
1
  • I see what you're going for, but I would like to have line 4 in the new column, whereas this code puts everything into the first column :/ Oct 7, 2013 at 2:33

You must log in to answer this question.

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