6

I would like to set a block followed by two additional ones below the first block. However, the widths and margins differ (see screenshot below). I'd like

  • the two narrower blocks to span across the same width as the wider block, and
  • the margins to remain unchanged.

How can I obtain that?

enter image description here

\documentclass{beamer}
\usetheme{Boadilla}

\begin{document}

\begin{frame}

\begin{block}{Guguck}
    Hallo du da, im Radio!
\end{block}

\begin{columns}
\column{0.5\linewidth}
    \begin{block}{Guguck}
        Hallo du da, im Radio!
    \end{block}

\column{0.5\linewidth}
    \begin{block}{Guguck}
        Hallo du da, im Radio!
    \end{block}
\end{columns}

\end{frame}
\end{document}

I can adjust the factor 0.5 to get the desired result, but that is an annoying work to do and probable not independent in changes of margins, textwidth etc.

EDIT: I used the option from samcarter, but it does not work properly. So I played around and find the option \setbeamertemplate{blocks}[default] which destroys the nice outlook. Here is the corresponding MWE. (I do not want to manipulate my first question.)

enter image description here

\documentclass{beamer}
\usetheme{Boadilla}
\setbeamertemplate{blocks}[default]

\begin{document}

\begin{frame}

\begin{block}{Block 1: Guguck}
    Hallo du da, im Radio!
\end{block}

\begin{columns}[onlytextwidth, t]
\column{0.45\linewidth}
    \begin{block}{Block 2a: Guguck und eine laengere Ueberschrift}
        \begin{itemize}
            \item a
            \item b
            \item c
        \end{itemize}
    \end{block}

\column{0.45\linewidth}
    \begin{block}{Block 2b: Guguck}
        Hallo du da, im Radio!
    \end{block}
\end{columns}

\end{frame}
\end{document}
Dirk
  • 2,728

2 Answers2

10

For rounded blocks simply use

\begin{columns}[onlytextwidth]
...
\end{columns}

enter image description here


Edit to address the OP's problem with the not-rounded default blocks

This can be done in two ways. First possibility is to change the totalwidth of the columns to get the desired effect:

\documentclass{beamer}
\usetheme{Boadilla}
\setbeamertemplate{blocks}[default]
\setbeamersize{text margin left=17.4mm,text margin right=10.6mm}

\begin{document}

    \begin{frame}

        \begin{block}{Block 1: Guguck}
            Hallo du da, im Radio!
        \end{block}

        \begin{columns}[t, totalwidth=1.02\textwidth]

            \begin{column}{0.45\linewidth}
                \begin{block}{Block 2a: Guguck und eine laengere Ueberschrift}
                    \begin{itemize}
                        \item a
                        \item b
                        \item c
                    \end{itemize}
                \end{block}
            \end{column}

            \begin{column}{0.45\linewidth}
                \begin{block}{Block 2b: Guguck}
                    Hallo du da, im Radio!
                \end{block}
            \end{column}

        \end{columns}

    \end{frame}
\end{document} 

enter image description here

However this requires fine-tuning of the scaling factor.


Redefinition of block-environment

Based on the answer https://tex.stackexchange.com/a/103974/36296 the problem is due to the fact that in the default theme blocks are based on the beamercolorboxs whereas in the rounded theme they are beamerboxesrounded.

To solve it, one can redefine the block environment.

\documentclass{beamer}
\usetheme{Boadilla}

\newsavebox{\squaredblocktext}
\setbeamertemplate{block begin}{
    \par\vskip\medskipamount%
    \makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
        \begin{beamercolorbox}[colsep*=.75ex]{block title}
            \usebeamerfont*{block title}\insertblocktitle%
        \end{beamercolorbox}}%
        \begin{lrbox}{\squaredblocktext}%
            \begin{minipage}[t]{\textwidth}%
                \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}

\setbeamertemplate{block end}{
            \end{minipage}%
        \end{lrbox}%
        {\parskip0pt\par}%
        \ifbeamercolorempty[bg]{block title}{}
        {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
        \usebeamerfont{block body}%
        \makebox[\dimexpr\textwidth-1.5ex\relax][l]{%
        \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
            \usebox{\squaredblocktext}
        \end{beamercolorbox}%
    }\vskip\smallskipamount%
}

\begin{document}
    \begin{frame}

        \begin{block}
            ab
        \end{block}

        \begin{columns}[totalwidth=\textwidth]
            \begin{column}{.48\textwidth}
                \begin{block}
                    ab
                \end{block}
            \end{column}
            \begin{column}{.48\textwidth}
                \begin{block}
                    ab
                \end{block}
            \end{column}
        \end{columns}

    \end{frame}
\end{document}

enter image description here

  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Well done on that first answer. – jub0bs Sep 06 '13 at 12:42
  • Thanks for your answer! As I described in my edit, I discovered, that another option of beamer destroys the option [onlytextwidth]. How can I correct this? – Dirk Sep 06 '13 at 13:47
2

I solved it by calculating the correct width of the columns environment to totalwidth=\dimexpr\paperwidth-5mm. However, this is not that flexible when changing margins. Is it possible to get the left/right text margin from beamer?

The complete MWE:

\documentclass{beamer}
\usetheme{Boadilla}
\setbeamertemplate{blocks}[default]

\begin{document}

\begin{frame}

\begin{block}{Block 1: Guguck}
    Hallo du da, im Radio!
\end{block}

\begin{columns}[t, totalwidth=\dimexpr\paperwidth-5mm]
\column{0.45\linewidth}
    \begin{block}{Block 2a: Guguck und eine laengere Ueberschrift}
        \begin{itemize}
            \item a
            \item b
            \item c
        \end{itemize}
    \end{block}

\column{0.45\linewidth}
    \begin{block}{Block 2b: Guguck}
        Hallo du da, im Radio!
    \end{block}
\end{columns}

\end{frame}
\end{document}
Dirk
  • 2,728