# Text justification within multicols environment

I'm using this 3-column layout.

\begin{multicols}{3}
[.. a lot of text ..]
\end{multicols}


I want to left-align the text in the left column, center the text in the middle column, and right-align the text in the right column. (Before you ask why anyone would want that: it's for a rather long list of names)

Of course, I can check which part of the text goes into which column, and justify the parts accordingly. But that's ugly. Can I tell LaTeX to do this for me?

-
Are single names split across the columns? It may be that the parcolumns package is more in line with what you want. –  Werner May 18 '12 at 16:03
Just to make it easier for people to answer, could you provide the source of a complete, compilable, but minimal dummy document to build upon? This is what we call a minimal working example (MWE), which is an essential part of most good questions. –  doncherry May 18 '12 at 16:12
basically the answer to your question is "no" but it seems better to give that as a comment rather than an answer. As (almost) always in TeX page and column breaking you can not change the typesetting at a page break as TeX first typesets more than needed then later chops up the scroll into the correct height and adds header and footer. Any renaming text is put back for consideration on the next page/column but it is put back as typeset boxes, not re-typeset. –  David Carlisle May 18 '12 at 16:13
Why don't you use a table with alignment {lcr}? Or you can use three minipages. –  Sigur May 18 '12 at 23:29

The following code repackages the columns as set by multicols, centre aligning the middle columns and aligning the right hand column flush right. It works for paragraphs as well as single lines, but would fail if there is any extra inter-line material (such as floats or specials).

\documentclass{article}

\textheight.3\textheight
\pdfpageheight2\textheight

\usepackage{multicol}

\makeatletter

\def\maybe@reverse@columns{%
\count@\mult@rightbox
\rejustifybox{\hskip 0pt \@plus 1filll\unhbox\z@\unskip}%
\rejustifybox{\hskip 0pt \@plus 1filll\unhbox\z@\unskip\hskip 0pt \@plus 1filll}%
}

\def\rejustifybox#1{%
\@tempdimb\ht\count@
\global\setbox\@ne\vbox{}%
\setbox\z@\vbox{\hbox{\vrule depth 123sp} \unvbox\count@
\loop
\setbox\z@\lastbox
\@tempskipa\lastskip\unskip
\@tempcnta\lastpenalty\unpenalty
\ifdim\dp\z@=123sp
\else
\global\setbox\@ne\vbox{%
\penalty\@tempcnta
\vskip\@tempskipa
\ifvoid\z@\else
\hbox to \wd\z@{#1}%
\fi
\unvbox\@ne}%
\repeat
\global\setbox\count@\box\@ne
\global\ht\count@\@tempdimb
}}

\makeatother

\def\a{One two three four five six seven. }
\def\b{\a Red green blue yellow. }
\def\c{\a\b\a\b}
\def\x{Oxford\par London\par Manchester\par Birmingham\par Nottingham\par Liverpool\par Cambridge\par}

\begin{document}

\begin{multicols}{3}\raggedright
1\c\c\par
2 Text goes here. \c\a\c\par
3 \x\x\x\x\x\x\x\x\x
\end{multicols}

\end{document}

-