Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following example shows that multicols treats pagebreaks as separate orderings.

\documentclass{article}

\usepackage[margin=0.5in]{geometry}\geometry{a4paper}
\usepackage{multicol,tikz}
\scrollmode

\begin{document}
\newcommand{\drawrect}[1]{\begin{tikzpicture} \draw (-1.5,-1.5) rectangle (1.5,1.5); \node at (0,0) {#1}; \end{tikzpicture}}

\begin{multicols}{3}\raggedright
\drawrect{1}
\drawrect{2}
\drawrect{3}
\drawrect{4}
\drawrect{5}
\drawrect{6}
\drawrect{7}
\drawrect{8}
\drawrect{9}
\drawrect{10}
\drawrect{11}
\drawrect{12}
\end{multicols}

\renewcommand{\drawrect}[1]{\begin{tikzpicture} \draw (-2.5,-3.5) rectangle (2.5,3.5); \node at (0,0) {#1}; \end{tikzpicture}}

\begin{multicols}{3}\raggedright
\drawrect{1}
\drawrect{2}
\drawrect{3}
\drawrect{4}
\drawrect{5}
\drawrect{6}
\drawrect{7}
\drawrect{8}
\drawrect{9}
\drawrect{10}
\drawrect{11}
\drawrect{12}
\end{multicols}

\end{document} 

I want the 2nd ordering to be exactly like the first.

Example using parcolumns:

\documentclass{article}

\usepackage[margin=0.5in]{geometry}\geometry{a4paper}
\usepackage{multicol,tikz}
\usepackage{parcolumns}
\scrollmode

\begin{document}
\newcommand{\drawrect}[1]{\begin{tikzpicture} \draw (-1.5,-1.5) rectangle (1.5,1.5); \node at (0,0) {#1}; \end{tikzpicture}}

\begin{parcolumns}[nofirstindent]{3}
\colchunk{
\drawrect{1}
\drawrect{2}
\drawrect{3}
\drawrect{4}}
\colchunk{
\drawrect{5}
\drawrect{6}
\drawrect{7}
\drawrect{8}}
\colchunk{
\drawrect{9}
\drawrect{10}
\drawrect{11}
\drawrect{12}}
\end{parcolumns}

\renewcommand{\drawrect}[1]{\begin{tikzpicture} \draw (-2.5,-3.5) rectangle (2.5,3.5); \node at (0,0) {#1}; \end{tikzpicture}}

\begin{parcolumns}[nofirstindent]{3}
\colchunk{
\drawrect{1}
\drawrect{2}
\drawrect{3}
\drawrect{4}}
\colchunk{
\drawrect{5}
\drawrect{6}
\drawrect{7}
\drawrect{8}}
\colchunk{
\drawrect{9}
\drawrect{10}
\drawrect{11}
\drawrect{12}}
\end{parcolumns}


\end{document} 
share|improve this question
    
Your MWE generates undefined command errors so it is hard to know if what we are seeing is what you intended. But multicol (as in most TeX) is designed to shipout each page as it comes, it can not wait until the end of the environment and back up after allocating the first n entries to the first column of each page, which is I think what you want. If your real case is distributing fixed large units such as tikz pictures and you know how many fit on a page, you can of course sort them in the source file to the correct order. Or if you want to force all out each picture in a longtable cell. –  David Carlisle May 9 '12 at 20:13
    
@DavidCarlisle I removed adjustwidth which was causing the problem. Your first solution is useless though as any changes to that may change the multicol could cause the order to change. (e.g., if it was on a page and you added stuff before and pushed it to fall on a break then the order would change... it would be extremely difficult to maintain). Unfortunately in my current case if I force them to all be on the same page I end up with a lot of wasted whitespace that could be utilized. –  Uiy May 9 '12 at 20:21
1  
You should consider using the parcolumns package then, although your code would have to manually distinguish between the columns. That is, the process is not as well-automated as in multicol. –  Werner May 9 '12 at 20:24
    
@Werner parcolumns does solve the order issue but now has alignment issues. It doesn't seem to properly align things though. I've attached an MWE using parcolumns. In my real case the code looks much better than the MWE though but it seems to center each element instead of left justify. –  Uiy May 9 '12 at 20:47
add comment

1 Answer

multicols is an environment to cut textual material into columns "for reading", and reading means restarting the process on the next page. So your example shows exactly what it should show. If that is not what you want then clearly multicols is not the solution for you.

What you seem to desire is to produce a table or a matrix (perhaps of non-textual material?) that should be allowed to break across pages. For this you could try longtable or supertabular they provide the structure over page boundaries, but then the input is horizontal while your ordering is still vertical (or so it seems).

share|improve this answer
    
The direction is not that important as I can rearrange it(although I'd rather keep it vertical in code since I already have it that way and it is easier to understand). The problem with tabular, and supertabular is they seem to wrap rows arbitrarily so I get rows with just one or two elements on them when there should be 3 equally spaced elements. It seems like it is something to do with using tikzpicture or the macros that generate the pictures. –  Uiy May 9 '12 at 21:29
    
@Uiy you haven't shown how you have used longtable/supertable etc but the intended usage is to put one tikzpicture in each cell so they would not wrap at all automatically. –  David Carlisle May 9 '12 at 22:34
    
@DavidCarlisle I used it like any other basic tabular. Used &'s as separators. With just plane text the table looks like. –  Uiy May 9 '12 at 23:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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