I am trying to introduce a few macros to make my life with columns in beamer a bit easier. The macros should take key-value pairs for customizing width, heights, alignment etc. I ran into problems using pgfkeys that don't get properly updated/initialized.
Below is a minimum example that I reduced to using only the column width as parameter. Here is what works and what doesn't:
- it works when I use two minipages and specify the column width (e.g.,
\leftcolumn[width=0.5]
); - when using minipages the default parameter of
\leftcolumn
in the frame does not work (try removing the[width=0.5]
); - using a
columns
environment (try uncommenting the block% --- Macros using columns...
works only for the first column but not for the second.
Any help or suggestions would be highly appreciated!
\documentclass[11pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\makeatletter
% Make sure the macros exist. They will hold the relative width.
\newcommand*\leftwidth{}
\newcommand*\rightwidth{}
\pgfkeys{
/slide/.cd ,
leftcolumn/width/.code = \def\leftwidth{#1} ,
leftcolumn/width/.default = 0.6 ,
rightcolumn/width/.code = \def\rightwidth{#1} ,
rightcolumn/width/.default = 0.4 ,
}
%%%%% Either use the following 3 macros or uncomment the %%%%
%%%%% 3 macros below (which use columns instead of minipages) %%%%
%%%%% and comment out the first 3 macros %%%%
% ------- Macros using minipages - they work OK -------
\newrobustcmd*\leftcolumn[1][]{
\pgfqkeys{/slide/leftcolumn}{#1}%
\begin{minipage}{\leftwidth\linewidth}
}
\newrobustcmd*\rightcolumn[1][]{
\end{minipage}\hfill
\pgfqkeys{/slide/rightcolumn}{#1}
\begin{minipage}{\rightwidth\linewidth}
}
\renewrobustcmd*\endcolumn{\end{minipage}}
% % ------- Macros using columns - they don't work -------
% \newrobustcmd*\leftcolumn[1][]{
% \begin{columns}
% \pgfqkeys{/slide/leftcolumn}{#1}%
% \column{\leftwidth\linewidth}
% left width: |\leftwidth| * linewidth\\[1em] % just some output
% }
%
% \newrobustcmd*\rightcolumn[1][]{
% \pgfqkeys{/slide/rightcolumn}{#1}
% \column{\rightwidth\linewidth}
% right width: |\rightwidth| * linewidth\\[1em] % \rightwidth is empty!
% }
%
% \renewrobustcmd*\endcolumn{
% \end{columns}
% }
\makeatother
\begin{document}
\begin{frame}[t]{}
Using two minipages works, except for the default values: removing the [width=0.5] does not fall back to the default value of 0.6.\\[1em]
\leftcolumn[width=0.5] % does not work without [...]!
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\rightcolumn[width=0.35]
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\endcolumn
\end{frame}
\end{document}
textpos
package. See par 12.8 of the beamer user guide..default
handler defines the value used if someone uses your key without value (ex:\leftcolumn[width]
). The.inital
handler defines the value used if your key is not used (ex:\leftcolumn
).