2

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.

1 Answer 1

3

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

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .