1

I am using the paracol package to add two columns to my document. In this document, I have an enumeration in each column and I want each item (which uses up multiple rows of text each, varying between left and right column) to be aligned vertically between the columns.

This is my basic setup so far:

\documentclass{article}

\nonstopmode

\usepackage[margin=2cm,twoside]{geometry} \usepackage[utf8]{inputenc} \usepackage{paracol} \usepackage[shortlabels]{enumitem} \usepackage[explicit]{titlesec} \usepackage[T1]{fontenc}

\begin{document}

\begin{paracol}{2} \begin{leftcolumn*}\noindent

\begin{enumerate}
    \item Foo \\
        Two line foo \\
        Three line foo
    \item Bar
    \item Baz
\end{enumerate}

\end{leftcolumn*}

\begin{rightcolumn}\noindent

\begin{enumerate}
    \item Foo
    \item Bar \\
        Two line bar
    \item Baz
\end{enumerate}

\end{rightcolumn}

\end{paracol}

\end{document}

Compiling this code results in the following output:

Actual Output

Is there an option to synchronize these enumerations, such that items 2. and 3. are at the same vertical position, that does not involve switching between columns after each item and manually restoring counters?

Palle
  • 93

1 Answers1

2

You don't have to put the enumerate outside the paracol, it just seems less redundant this way.

\documentclass{article}

\nonstopmode

\usepackage[margin=2cm,twoside]{geometry} \usepackage[utf8]{inputenc} \usepackage{paracol} \usepackage[shortlabels]{enumitem} \usepackage[explicit]{titlesec} \usepackage[T1]{fontenc}

\begin{document}

\begin{enumerate} \begin{paracol}{2} \item Foo \ Two line foo \ Three line foo \switchcolumn \item Foo \switchcolumn* \item Bar \switchcolumn \item Bar \ Two line bar \switchcolumn* \item Baz \switchcolumn \item Baz \end{paracol} \end{enumerate}

\end{document}

demo


This version uses \synchcolumns to input the columns separately, using \synch to locate alignment points. There is no test for unequal numbers.

(My first attempt was based on \@next, but it wanted to expand \item. The main difficulty with this approach is that I was losing the gaps between the items.)

\documentclass{article}

\nonstopmode

\usepackage[margin=2cm,twoside]{geometry} \usepackage[utf8]{inputenc} \usepackage{paracol} \usepackage[shortlabels]{enumitem} \usepackage[explicit]{titlesec} \usepackage[T1]{fontenc}

\makeatletter \newsavebox{\left@col} \newsavebox{\right@col}

\newcommand{\synchcolumns}[2]{% #1 = left column, #2 = right column \switchcolumn[0]* \let\synch=\pagebreak \setbox\left@col=\vbox{#1}% \switchcolumn[1] \setbox\right@col=\vbox{#2}% \switchcolumn[0] \bgroup \loop \dimen0=\ht\left@col \setbox0=\vsplit\left@col to \dimen0 \advance\dimen0 by -\ht\left@col \setbox1=\vbox{\unvbox0}% \ht0 not useful \advance\dimen0 by -\ht1 \unvbox1 \vskip\dimen0 \switchcolumn[1] \dimen0=\ht\right@col \setbox0=\vsplit\right@col to \dimen0 \advance\dimen0 by -\ht\right@col \setbox1=\vbox{\unvbox0}% \advance\dimen0 by -\ht1 \unvbox1 \vskip\dimen0 \switchcolumn[0]* \ifvoid\left@col \else\repeat \egroup} \makeatother

\begin{document}

\begin{enumerate} \begin{paracol}{2} \synchcolumns{% \item Foo \ Two line foo \ Three line foo \synch \item Bar \synch \item Baz }{% \item Foo \synch \item Bar \ Two line bar \synch \item Baz } \end{paracol} \end{enumerate}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thanks. Is there a way how I can do this and still keep the left and right columns separate (i.e. not interleaved) in the LaTeX source? – Palle Aug 26 '21 at 13:47