Solution
\newlength{\blockleftindent}
\newlength{\blockrightindent}
\setlength\blockleftindent{10ex}
\setlength\blockrightindent{20ex}
\newlength{\blockwidth}
\setbeamertemplate{block begin}{
\setlength\blockwidth{\linewidth}
\addtolength\blockwidth{-\blockleftindent}
\addtolength\blockwidth{-\blockrightindent}
\par\vskip\medskipamount%
\hspace*{\blockleftindent}%
\begin{beamercolorbox}[colsep*=.75ex,wd=\blockwidth]{block title}
\usebeamerfont*{block title}\insertblocktitle%
\end{beamercolorbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title}
{}
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\hspace*{\blockleftindent}%
\begin{beamercolorbox}[colsep*=.75ex,wd=\blockwidth,vmode]{block body}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
Instead of using \hspace
you could set \leftskip=\blockleftindent
as suggested in the solution by @Herbert.
Explanation
The problem is that you cannot achieve that using \addtobeamertemplate
: if you look at how the template is defined in beamerinnerthemedefault.sty
\defbeamertemplate*{block begin}{default}
{
\par\vskip\medskipamount%
\begin{beamercolorbox}[colsep*=.75ex]{block title}
\usebeamerfont*{block title}\insertblocktitle%
\end{beamercolorbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title}
{}
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
\ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
you see that if you add code at the beginning, you are acting just before a \par
is issued. So, unless you want to use black magic to have your code swallow the \par
, you have to copy over the definition and change it according to your needs with \setbeamertemplate
. Here I achieve the indentation simply by putting some \hspace
before the two beamercolorbox
es that contain the title and the contents. Other means to add that horizontal space may be used.
The alternative with \leftskip
could be implemented using \addtobeamertemplate
since the new \leftskip
value would be used later when creating the beamerboxes
. However to change the indentation on the right you need to modify the wd
key of the beamer box environment, which requires again to use \setbeamertemplate
.