How to horizontally align beamer columns with surrounding text

If you (like me) assumed that placing two columns width 50% of textwidth next to each other would align with preceding or following text on a beamer slide, then you are mistaken (like me).

Fortunately, a discussion on Bug #262: Provide more usable columns environment showed a viable solution in form of the optional argument onlytextwidth.

However, in order to use it successfully, one must then take care of spacing oneself. Here is my result of some experimentation:

beamer-columns-to-textwidth

Here is the corresponding document source code:

\documentclass{beamer}
\usepackage{mathtools}
\usepackage{listings}
\lstset{basicstyle=\ttfamily}

\usepackage{hyperref}

\begin{document}
\begin{frame}{Testing columns spacing}{How to achieve 
correctly spaced columns with beamer}
\emph{The documentation doesn't tell you anything about 
the alignment of the columns or the space in between them.
In particular, the side effect of totalwidth (which 
changes the columns to be left aligned within the 
textarea of the slide rather than center aligned on the 
page).}
\vspace{.5cm}
\begin{columns}[t,onlytextwidth]
\begin{column}{.5\textwidth-.25cm}
This slide shows the successfull result to align the 
margins of these two columns with the surrounding text to 
exactly \lstinline{\\textwidth}.
\end{column}
\begin{column}{.5\textwidth-.25cm}
What to do?

Do your own math and specify column widths with spacing. 
These columns have equal width of 
\lstinline{.5\\textwidth-.25cm}.
\end{column}
\end{columns}
\vspace{.5cm}
From: 
\href{https://bitbucket.org/rivanvx/beamer/
issue/262/provide-more-usable-columns-environment}
{Issue \#262}: Provide more usable columns environment}
\end{frame}
\end{document}

Leave a Reply

Your email address will not be published. Required fields are marked *