1

Related to this question I would like to permanently widen the width of blocks in beamer.

The effect should be that of block at the bottom of the picture, whereas the block at the top is the standard dimension.

enter image description here


Thanks to Gonzalo's answer the temporary solution is:

\documentclass[10pt]{beamer}
\usetheme{Warsaw}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\makeatother
\newlength\myblockwd
\setlength\myblockwd{0.95\paperwidth}
\newlength\mylen
\setlength\mylen{\dimexpr\myblockwd-\textwidth\relax}

\makeatletter
\defbeamertemplate{block begin}{myrounded}[1][]
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true,width=\myblockwd]%
    {\raggedright\usebeamerfont*{block title}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body}%
}
\defbeamertemplate{block end}{myrounded}[1][]
{\end{beamerboxesrounded}\vskip\smallskipamount}

\defbeamertemplate{block alerted begin}{myrounded}[1][]
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title alerted,lower=block body alerted,,width=\myblockwd]%
    {\raggedright\usebeamerfont*{block title alerted}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body alerted}%
}%
\defbeamertemplate{block alerted end}{myrounded}[1][]
{\end{beamerboxesrounded}\vskip\smallskipamount}

\defbeamertemplate{block example begin}{myrounded}[1][]
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title example,lower=block body example,width=\myblockwd]
    {\raggedright\usebeamerfont*{block title example}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body example}%
}%
\defbeamertemplate{block example end}{myrounded}[1][]
{\end{beamerboxesrounded}\vskip\smallskipamount}

\setbeamertemplate{block begin}[myrounded]
\setbeamertemplate{block alerted begin}[myrounded]
\setbeamertemplate{block example begin}[myrounded]

\makeatother
\title{title}
\author{Name Surname}
\date{date\\ place}
\begin{document}

\begin{frame}
\titlepage
\end{frame}

\section{Section}
\frame{\sectionpage}
\subsection{subsection}
\frame{
\frametitle{title}
\begin{block}{title}
title
\begin{itemize}
\item {title};
\item {title};
\item {title};
\item {title};
\end{itemize}
\end{block}

\begin{block}{title}
title
\begin{itemize}
\item {title};
\item {title};
\item {title};
\item {title};
\end{itemize}
\end{block}
}

\frame{
\frametitle{Title}
\begin{columns}
\begin{column}{1.7in}
\begin{block}<1->{title}
\begin{itemize}
\item title;
\item title;
\item title;
\end{itemize}
\end{block}
\end{column}

\begin{column}{1.7in}
\begin{block}<1->{title}
\begin{itemize}
\item title;
\item title;
\item title;
\end{itemize}
\end{block}
\end{column}
\end{columns}
}

\end{document}

that is great for "standard" frame:

enter image description here

but it is not good when a frame is divided into two columns and blocks are somehow "aligned" horizontally:

enter image description here

So, now the problem is to make blocks able to resize automatically when they are arranged into columns.

2

Update

Here's one option, defining wblock, walterblock and wexampleblock` environments which behave as the original (without the "w") ones but with controllable width:

\documentclass{beamer} 
\usetheme{Warsaw}

\newlength\myblockwd
\setlength\myblockwd{0.95\paperwidth}
\newlength\mylen
\setlength\mylen{\dimexpr\myblockwd-\textwidth\relax}

\makeatletter
\defbeamertemplate{block begin}{myrounded}
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title,lower=block body,shadow=true,width=\myblockwd]%
    {\raggedright\usebeamerfont*{block title}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body}%
}
\defbeamertemplate{block end}{myrounded}
{\end{beamerboxesrounded}\vskip\smallskipamount}

\defbeamertemplate{block alerted begin}{myrounded}
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title alerted,lower=block body alerted,shadow=true,width=\myblockwd]%
    {\raggedright\usebeamerfont*{block title alerted}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body alerted}%
}%
\defbeamertemplate{block alerted end}{myrounded}[1][]
{\end{beamerboxesrounded}\vskip\smallskipamount}

\defbeamertemplate{block example begin}{myrounded}
{
  \par\vskip\medskipamount%
  \hspace*{-0.5\mylen}\begin{beamerboxesrounded}[upper=block title example,lower=block body example,shadow=true,width=\myblockwd]
    {\raggedright\usebeamerfont*{block title example}\insertblocktitle}%
    \raggedright%
    \usebeamerfont{block body example}%
}%
\defbeamertemplate{block example end}{myrounded}[1][]
{\end{beamerboxesrounded}\vskip\smallskipamount}

  \newenvironment<>{wblock}[1]{%
    \begin{actionenv}#2%
      \setbeamertemplate{block begin}[myrounded]%
      \def\insertblocktitle{#1}%
      \par%
      \usebeamertemplate{block begin}}
    {\par%
      \usebeamertemplate{block end}%
    \end{actionenv}}

  \newenvironment<>{walertblock}[1]{%
    \begin{actionenv}#2%
      \setbeamertemplate{block alerted begin}[myrounded]%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%\usebeamerfont{block}%
        \setbeamercolor{local structure}{parent=alerted text}}%
      \usebeamertemplate{block alerted begin}}
    {\par%
      \usebeamertemplate{block alerted end}%
    \end{actionenv}}

  \newenvironment<>{wexampleblock}[1]{%
    \begin{actionenv}#2%
      \setbeamertemplate{block example begin}[myrounded]%
      \def\insertblocktitle{#1}%
      \par%
      \mode<presentation>{%\usebeamerfont{block}%
        \setbeamercolor{local structure}{parent=example text}}%
      \usebeamertemplate{block example begin}}
    {\par%
      \usebeamertemplate{block example end}%
    \end{actionenv}}
\makeatother

\begin{document}

\begin{frame}
\begin{wblock}{An example block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{wblock}
\begin{walertblock}{An example alerted block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{walertblock}
\begin{wexampleblock}{An example example block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{wexampleblock}
\end{frame}

\begin{frame}
\begin{columns}
\column{0.5\textwidth}
\begin{block}{An example block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{block}
\begin{alertblock}{An example alerted block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{alertblock}
\column{0.5\textwidth}
\begin{exampleblock}{An example example block}
\begin{itemize}
\item First.
\item Second.
\end{itemize}
\end{exampleblock}
\end{columns}
\end{frame}

\end{document}

I used 0.95\paperwidth as the new width for blocks, but you can get the desired value by setting the length \myblockwd.

enter image description here

  • Gonzalo, your answer is great, but there is a problem when a frame is divided into two columns. In that case, blocks are not able to automatically resize. I have just edited my question. – werty Sep 3 '15 at 17:36
  • @werty Please see my updated answer. – Gonzalo Medina Sep 3 '15 at 17:57
  • One final comment before I accept your answer. Why are wexampleblock and walertblock not shaded? – werty Sep 3 '15 at 18:49
  • @werty Sorry about that; I fotgot the shadow for those blocks. In the updated answer the shadows are back. – Gonzalo Medina Sep 3 '15 at 19:05

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.