For a documentation I am having a special chapter where there are a lot of code listings, compared to the amount of prose text. What I would like to end up with is a two column layout, where the left column is used for the prose text only and the right column is used for code listings only.
The following creates a two page double column document, where the left column always says FOO and the right column only says BAR.
\documentclass{article}
\usepackage{multicol}
\usepackage{multido}
\begin{document}
\begin{multicols}{2}
\noindent \multido{}{322}{FOO } \multido{}{322}{BAR }
\multido{}{322}{FOO } \multido{}{322}{BAR }
\end{multicols}
\end{document}
I want the same effect, but without manually chopping up my input. I want a macro and/or an environment which I tell \multido{}{644}{FOO }
and \multido{}{644}{BAR }
and it automagically does the page/column breaking as illustrated by the example above.
Is there an environment that does this? Does anybody see a simple and quickway to achieving this?
WIP:
I've been trying a hack or two, but kept failing. The thing is, a page break in the left column must make the text continue in the left column of the next page. A page break in the right column must make the listings continue in the right column of the next page. My core idea was I have two "input-saveboxes" A and B and whenever LaTeX encounters a column break in a multicols
environment it switches over to the other input-savebox.
But I never got close to implement anything like that. My best looking attemt was \hsize=.5\hsize
and use \makebox
to generate boxes that have neither width, nor height nor depth, but contain other boxes which carefully place the listings. Using this approach I cannot make listings break at the end of pages/columns.
There may be a way using a combination of flowfram
as described in this answer and multicols
:
- have a
multicols
with one column inside astaticcontent
environment - bewitch
\pagebreak
inside themulticolumn
environment to do a\continueonframe
in combination with\refstepcounter
I'll try this next while hoping for a ready to use solution ...
Update
The bewitching \pagebreak
idea was based on some properties I thought the multicols
environment had. Seems like I only immagined those. I still think multicols could be hacked to do what I want, because it already follows the approach of eating away form \box\partial@page
. By adding a prefilled second box for partial pages and alternating output this could be done. However, this is a bigger project I won't be able to complete in time. And I'm still guessing a lot, because my TeX is not that good and reading Frank's TeX is almost as challenging as reading Perl code.
\textsize
reduced to one column width, then increase\marginparwidth
by the same amount, then you can put your listings in the margin using standard marginpar or one of the packages that re-implement that.\vsplit
is the command that might help a lot. @DavidCarlisle: I couldn't find marginpar implementations that could do pagebreaks.