6

How do I change the background color of a column in Beamer? (the entire column)

(This is a simple question, but for the life of me, I cannot not find an answer.)

Example:

\documentclass[t]{beamer}
\setbeamersize{text margin left=1em, text margin right=1em}
\begin{document}

\begin{frame}{Test}
\begin{columns}[t,onlytextwidth]
\begin{column}{0.5\textwidth}
Some text.
\end{column}
\begin{column}{0.5\textwidth}
Some question.
\[1+1=2\]
\end{column}
\end{columns}
\end{frame}

\end{document}

What I would like:

example desired result

4

Two options.

  1. Since minipage lets you control its height, instead of columns I'd rather use two side-by-side minipages, enclosing one of them in a \colorbox:

    enter image description here

    The code:

    \documentclass[t]{beamer}
    \setbeamersize{text margin left=1em, text margin right=1em}
    \begin{document}
    
    \begin{frame}
    \frametitle{Test}
    
    \colorbox{blue!20}{\begin{minipage}[t][0.8\textheight][t]
    {\dimexpr0.5\textwidth-2\fboxsep-2\fboxrule-5pt\relax}
    Some text.
    \end{minipage}}\hfill
    \begin{minipage}[t][0.8\textheight][t]
    {\dimexpr0.5\textwidth-5pt\relax}
    Some question.
    \[1+1=2\]
    \end{minipage}
    \end{frame}
    
    \end{document}
    
  2. Using a tabular and \columncolor; an invidible \rule of appropriate depth allows you to vertically extend the colorized colum:

    enter image description here

    \documentclass[table]{beamer}
    \setbeamersize{text margin left=1em, text margin right=1em}
    \begin{document}
    
    \begin{frame}[t]
    \frametitle{Test}
    
    \begin{tabular}[t]{@{}>{\columncolor{blue!20}\rule[-.8\textheight]{0pt}{0pt}}p{\dimexpr.5\textwidth-\tabcolsep\relax}p{\dimexpr.5\textwidth-\tabcolsep\relax}@{}}
    Some text. & 
    Some question.
    \[1+1=2\]
    \end{tabular}
    \end{frame}
    
    \end{document}
    
  • I am going to give other ppl a chance at answering this; but yeah, I think I will just go with minipages ... – Ricardo Cruz Jul 18 '15 at 14:08
  • @RicardoCruz In the meantime I updated my answer with another (simpler) option using a tabular. – Gonzalo Medina Jul 18 '15 at 16:05
  • A possible alternative as well... Thank you! – Ricardo Cruz Jul 20 '15 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.