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.

I am looking for a three-column layout, in which two columns contain two seperate lists, and the third column a summary of the two lists.

Mockup

I am under the impression that there is no "native" way to do this in LaTeX (and haven't found a package that appears to do the trick), so in a first step I have prepared a custom environment and a custom item entry macro:

\documentclass{scrbook}
\usepackage{multicol}
\newenvironment{MyList}[1]{
    \subsection{#1}
    \begin{enumerate}
}{
    \end{enumerate}
}
\newcommand{\myEntry}[2]{\item \textbf{#1} -- #2}
\begin{document}
\begin{multicols}{3}
\begin{MyList}{ListOne}
\myEntry{OneOne}{Some text regarding item OneOne}
\myEntry{OneTwo}{Some text regarding item OneTwo}
\end{MyList}
\columnbreak
\begin{MyList}{ListTwo}
\myEntry{TwoOne}{Some text regarding item TwoOne}
\myEntry{TwoTwo}{Some text regarding item TwoTwo}
\end{MyList}
\columnbreak
\end{multicols}
\end{document}

But that does not even take me half of the way. I need to render the contents of my macros twice: Once in the summary column, once in the individual list column. Not only that, but on the opposite page I would have to do it the other way around (i.e., individual column first, summary column second). It's pretty clear that no simple replace-this-with-that transformation can do that, and that some "programming" is required, but I have no idea if there is some way to do this in LaTeX.

I could probably write some Perl script to do it via a preprocessing step, but boy does that feel hack-ish...

If there is a way to do this in LaTeX, could someone please give me some pointers what to look for?

share|improve this question
1  
One way to repeat stuff is to save it as a macro. So change your \myEntry to include \def\tempmacro{#1} so later you can use \tempmacro to repeat the stuff. This won't work because you want to repeat it after having gone through the whole list. So you'd need to namespace all your macros properly. If you could do things as a tabular instead, then this method would be easier. –  Seamus Aug 19 '11 at 10:57
    
Otherwise, you can write things to an auxiliary file and print that back out as the third column. –  Seamus Aug 19 '11 at 11:03
    
@Seamus: Would you care to turn this into an answer? I think this is the right way to go but would have to play Q&A for a round or two on this (and would like to give it the "checkmark of thanks" if it floats my boat). –  DevSolar Aug 19 '11 at 11:06

1 Answer 1

up vote 2 down vote accepted

Here's how to do this with a new auxiliary file:

\documentclass{scrbook}
\usepackage{multicol}
\newenvironment{MyList}[1]{
  \addtostream{summary}{\noexpand\paragraph{#1}%
  \noexpand\begin{enumerate}
  }
    \subsection{#1}
    \begin{enumerate}
}{
    \end{enumerate}
    \addtostream{summary}{\noexpand\end{enumerate}}
}

\newcommand{\myEntry}[2]{%
  \addtostream{summary}{\noexpand\item \noexpand\textbf{#1}}%
  \item \textbf{#1} -- #2
}


\usepackage{newfile} 
\newoutputstream{summary}
\newcommand\dosummary{%
\closeoutputstream{summary}
\subsection{Summary}
\input{\jobname.sum}
}
\openoutputfile{\jobname.sum}{summary}
\begin{document}
\begin{multicols}{3}
\begin{MyList}{ListOne}
\myEntry{OneOne}{Some text regarding item OneOne}
\myEntry{OneTwo}{Some text regarding item OneTwo}
\end{MyList}
\columnbreak
\begin{MyList}{ListTwo}
\myEntry{TwoOne}{Some text regarding item TwoOne}
\myEntry{TwoTwo}{Some text regarding item TwoTwo}
\end{MyList}
\columnbreak
\dosummary
\end{multicols}

\end{document}

The important stuff is the newfile package which makes writing to files easier, and the \addtostream command which actually adds stuff to the auxiliary file. You have to be careful about macros being expanded when writing things to files, hence the \noexpands in front of the \items.

I've modified the MyList environment and the \myEntry macro to write the relevant things to the auxiliary file which is then printed out by the \dosummary macro. Find out more about auxiliary files here.

share|improve this answer
1  
Might need compiling twice, by the way. –  Seamus Aug 19 '11 at 11:32
    
That's definitely the hint I've been looking for. It will need some additional tinkering (as my example was much dumbed down for simplicity's sake), but I can "see the path" now (even without additional Q&A). Thanks (again)! –  DevSolar Aug 19 '11 at 14:02
    
One question though: Will this auxiliary file be included in the same pass it is created? I.e., could this process be repeated (and the summary output stream be "recycled"), or would I have to create a new output stream (possibly numbered with help of \thesubsection or somesuch) for every instance of MyList? –  DevSolar Aug 19 '11 at 15:39
    
Nevermind. Tested it, it works just fine. –  DevSolar Aug 19 '11 at 17:18

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.