# vertical alignment of two columns in a beamer frame

I'm trying present two concepts side by side in a frame. And I want each lineitem to be vertically aligned. Here is is an example where they are not aligned.

\begin{frame}{An Example of using columns in beamer}

\begin{columns}

\begin{column}{0.48\textwidth}
\color{red}\rule{\linewidth}{4pt}
foo
\begin{itemize}
\item this is line 1 of foo
\item this is line 2 of foo which is long
\item this is line 3 of foo
\end{itemize}
\end{column}

\begin{column}{0.48\textwidth}
\color{blue}\rule{\linewidth}{4pt}
bar
\begin{itemize}
\item this is line 1 of bar
\item this is line 2 of bar
\item need this line to be aligned with line 3 of foo
\end{itemize}
\end{column}

\end{columns}

\end{frame}


One way is to add some phantom text in both columns so that each bullet points "takes" up the same number of lines:

## Notes:

• Also added [t] to align the columns at the top

## Code:

\documentclass{beamer}

\begin{document}
\begin{frame}{An Example of using columns in beamer}

\begin{columns}

\begin{column}[t]{0.48\textwidth}
\color{red}\rule{\linewidth}{4pt}
foo
\begin{itemize}
\item this is line 1 of foo
\item this is line 2 of foo which is long
\item this is line 3 of foo
\end{itemize}
\end{column}

\begin{column}[t]{0.48\textwidth}
\color{blue}\rule{\linewidth}{4pt}
bar
\begin{itemize}
\item this is line 1 of bar
\item this is line 2 of bar \phantom{which is long}
\item need this line to be aligned with line 3 of foo
\end{itemize}
\end{column}

\end{columns}

\end{frame}
\end{document}

• Thank you. It worked!! But I feel this is not an elegant way to do it. Very often, people try to compare and contrast two things in a frame and there should be a easy way to do it. – arunmoezhi Oct 31 '14 at 22:02
• @arunmoezhi: Have modified solution since I first posted it, so slightly simpler, but still involves \phantom{} spacing (but only one one of the \items). I am not much of a beamer expert so perhaps there is a more elegant way in beamer. I do know of other more complicated ways in case you do this very often which would involve packaging a similar process into a macro, but I think using \phantom{} is a common way to tweak things. – Peter Grill Oct 31 '14 at 22:06
• I'm fine with this simple tweak using \phantom{}. But I just thought someone else might need this feature frequently. – arunmoezhi Oct 31 '14 at 22:09

Here is a solution via two new commands : \parallelcontent and \parallelitem.

\documentclass{beamer}

\newcommand\parallelcontent[2]{
\begin{columns}[t]
\column{0.48\textwidth} #1
\column{0.48\textwidth} #2
\end{columns}
}
\newcommand\parallelitem[2]{
\parallelcontent
{\begin{itemize} \item #1 \end{itemize}}
{\begin{itemize} \item #2 \end{itemize}}
}

\begin{document}
\begin{frame}{An Example of using columns in beamer}

\parallelcontent
{\textcolor{red}{\rule{\linewidth}{4pt} foo}}
{\textcolor{blue}{\rule{\linewidth}{4pt} bar}}
\parallelitem
{this is line 1 of foo}
{this is line 1 of bar}
\parallelitem
{this is line 2 of foo which is long}
{this is line 2 of bar}
\parallelitem
{this is line 3 of foo}
{need this line to be aligned with line 3 of foo}

\end{frame}
\end{document}


• What if there's a different number of items in the two lists? I mean, in the question the reason for misalignment is due to the different lenght of the texts in the two items of a couple. Another reason could be that one of the two lists has some missing item. – Enrico Maria De Angelis Oct 25 '16 at 10:12
• @EnricoMariaDeAngelis In this case, you may use \parallelcontent with an empty part (for the missing part)... – Paul Gaborit Oct 25 '16 at 10:28
• Do you mean using \parallelcontent insted of \parallelitem, and manually insert itemize environment in one of the two arguments of \parallelcontent? – Enrico Maria De Angelis Oct 25 '16 at 11:50
• @EnricoMariaDeAngelis Exactly. – Paul Gaborit Oct 25 '16 at 22:09