0

I want to use the block environment together with the column environment in a beamer document.

The margin/spacing is getting wrong/ugly in this combination. I want that the blocks are exactly as wide as a normal text would occupy (so that the text margins are still correct).

\documentclass{beamer}

\setbeamersize{text margin left=5mm}
\setbeamersize{text margin right=5mm}

\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=yellow}

\begin{document}

% Frame 1 -----------------------
\begin{frame}
\frametitle{No Column Environment}
    \begin{block}{Block Title}
    Block Text.
    \end{block}
\end{frame}

% Frame 2 -----------------------
\begin{frame}
\frametitle{Column Environment -- Only Left Block Environment}

\begin{columns}
    \column{.50\textwidth}
        \begin{block}{Block Title}
        Block Text.
        \end{block}
    \column{.50\textwidth}
        \color{blue}\vrule width\textwidth height\textwidth
\end{columns}
\end{frame}

% Frame 3 -----------------------
\begin{frame}
\frametitle{Column Environment -- Left and Right Block Environment}

\begin{columns}
    \column{.50\textwidth}
        \begin{block}{Block Title}
        Block Text.
        \end{block}
    \column{.50\textwidth} 
        \begin{block}{Block Title}
        Block Text.
        \end{block} 
\end{columns}
\end{frame}

% Frame 4 -----------------------
\begin{frame}
\frametitle{Column Environment Only}

\begin{columns}
    \column{.50\textwidth}
        \color{blue}\vrule width\textwidth height\textwidth
    \column{.50\textwidth}
        \color{blue}\vrule width\textwidth height\textwidth
\end{columns}
\end{frame}

\end{document}

enter image description here

The reason for the yellow background is, so that it is clear where the page has its borders.

Trying the idea from samcarter in one of the comments leads to.

\begin{frame}
    \begin{columns}[onlytextwidth] 
        \begin{column}{.45\textwidth} 
        \begin{block}{Block Title} Block Text. 
        \end{block}%
        \end{column} \hfill%
        \begin{column}{.45\textwidth} 
        \begin{block}{Block Title} Block Text. 
        \end{block} 
        \end{column} 
    \end{columns}
    \begin{block}{Block Title}
    Block Text.
    \end{block}
\end{frame}

enter image description here


Bug?! I Opened an Issue on GitHub


Similar or Duplicate or Related

1 Answers1

5

Setting the width of the columns environment to fixed value will solve your issue. You can do so i.e. using the option [onlytextwidth]:

\documentclass{beamer}

\setbeamersize{text margin left=5mm}
\setbeamersize{text margin right=5mm}

\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=yellow}

\begin{document}

% Frame 1 -----------------------
\begin{frame}
\frametitle{No Column Environment}
    \begin{block}{Block Title}
    Block Text.
    \end{block}
\end{frame}

% Frame 2 -----------------------
\begin{frame}
\frametitle{Column Environment -- Only Left Block Environment}

\begin{columns}[onlytextwidth]
    \column{.47\textwidth}
        \begin{block}{Block Title}
        Block Text.
        \end{block}
    \column{.47\textwidth}
        Right Column Text.
\end{columns}
\end{frame}

% Frame 3 -----------------------
\begin{frame}
\frametitle{Column Environment -- Left and Right Block Environment}

\begin{columns}[onlytextwidth]
    \column{.47\textwidth}
        \begin{block}{Block Title}
        Block Text.
        \end{block}
    \column{.47\textwidth}
        \begin{block}{Block Title}
        Block Text.
        \end{block}
\end{columns}
\end{frame}

\end{document}

enter image description here

(You have to do some fine tuning of the widths of the actual columns)

DG'
  • 21,727