New attempt
- My first attempt directly patches the list environment.
- This new attempt patches
beamercolorbox
by updating the line width used by list environments. Note that beamercolorbox
adds the value passed to sep
option to \leftskip
and \rightskip
, but the line width is not updated.
% put these lines in preamble
\usepackage{xpatch}
\makeatletter
% originally defined in beamerbasecolor.sty
\xpatchcmd\beamercolorbox
{%
\leftskip=\beamer@colbox@ls%
\ifdim\beamer@colbox@sep>\z@\advance\leftskip\beamer@colbox@sep\fi%
\rightskip=\beamer@colbox@rs%
\ifdim\beamer@colbox@sep>\z@\advance\rightskip\beamer@colbox@sep\fi
}
{%
\leftskip=\beamer@colbox@ls%
\ifdim\beamer@colbox@sep>\z@
\advance\leftskip\beamer@colbox@sep
\advance\linewidth-\beamer@colbox@sep % added
\advance\@totalleftmargin\beamer@colbox@sep % added
\fi%
\rightskip=\beamer@colbox@rs%
\ifdim\beamer@colbox@sep>\z@
\advance\rightskip\beamer@colbox@sep
\advance\linewidth-\beamer@colbox@sep % added
\fi
}
{}{\fail}
\makeatother
Variant for beamer
v3.36, which is used by OP
% put these lines in preamble
\usepackage{xpatch}
% originally defined in beamerbasecolor.sty, beamer v3.36
% see https://github.com/josephwright/beamer/blob/v3.36/base/beamerbasecolor.sty
\makeatletter
\xpatchcmd\beamercolorbox
{%
\leftskip=\beamer@colbox@ls%
\advance\leftskip by\beamer@colbox@sep%
\rightskip=\beamer@colbox@rs%
\advance\rightskip by\beamer@colbox@sep
}
{%
\leftskip=\beamer@colbox@ls%
\ifdim\beamer@colbox@sep>\z@
\advance\leftskip\beamer@colbox@sep
\advance\linewidth-\beamer@colbox@sep % added
\advance\@totalleftmargin\beamer@colbox@sep % added
\fi%
\rightskip=\beamer@colbox@rs%
\ifdim\beamer@colbox@sep>\z@
\advance\rightskip\beamer@colbox@sep
\advance\linewidth-\beamer@colbox@sep % added
\fi
}
{}{\fail}
\makeatother
First attempt
\documentclass{beamer}
\setbeamercolor{box}{fg=black,bg=gray!30}
\makeatletter
\patchcmd\beamer@enum@
{\usecounter\@enumctr}
{%
\usecounter\@enumctr
% patch into the second argument of \list
% here \beamer@colbox@sep stores the value passed to option sep
\addtolength{\leftmargin}{\beamer@colbox@sep}%
\addtolength{\rightmargin}{\beamer@colbox@sep}%
}
{}{\fail}
\makeatother
\begin{document}
\begin{frame}
\begin{beamercolorbox}[sep=30pt]{box}
Some text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\begin{enumerate}
\item First list item. First list item. First list item. First list item. First list item.
\item Second list item. Second list item. Second list item. Second list item. Second list item.
\end{enumerate}
As can be seen, the enumeration is \emph{not} separated 30 pt from the border of the box.
\end{beamercolorbox}
\end{frame}
\end{document}

Update to first attempt
This further example contains the similar patches for itemize
and description
environments as well.
- Because of how
\itemized
is defined, we need \xpatchcmd
from xpatch
package to do the patching. Hence I replaced all \patchcmd
by \xpatchcmd
.
\documentclass{beamer}
\setbeamercolor{box}{fg=black,bg=gray!30}
\usepackage{xpatch}
\makeatletter
% patch enumerate
\xpatchcmd\beamer@enum@
{\usecounter\@enumctr}
{%
\usecounter\@enumctr
% patch into the second argument of \list
% here \beamer@colbox@sep stores the value passed to option sep
\addtolength{\leftmargin}{\beamer@colbox@sep}%
\addtolength{\rightmargin}{\beamer@colbox@sep}%
}
{}{\fail}
% patch itemize
\xpatchcmd\itemize
{\def\makelabel}
{%
\addtolength{\leftmargin}{\beamer@colbox@sep}%
\addtolength{\rightmargin}{\beamer@colbox@sep}%
\def\makelabel
}
{}{\fail}
% patch description
\xpatchcmd\@@description
{\let\makelabel\beamer@descriptionitem}
{%
\let\makelabel\beamer@descriptionitem
\addtolength{\leftmargin}{\beamer@colbox@sep}%
\addtolength{\rightmargin}{\beamer@colbox@sep}%
}
{}{\fail}
\makeatother
\begin{document}
\begin{frame}
\begin{beamercolorbox}[sep=30pt]{box}
Some text text text text text text text text text text text text text text
\begin{enumerate}
\item First list item. First list item. First list item. First list item. First list item.
\item Second list item. Second list item. Second list item. Second list item. Second list item.
\end{enumerate}
As can be seen, the enumeration is now separated 30pt from the border of the box.
\end{beamercolorbox}
\end{frame}
\begin{frame}
\begin{beamercolorbox}[sep=30pt]{box}
Some text text text text text text text text text text text text text text
\begin{itemize}
\item First list item. First list item. First list item. First list item. First list item.
\item Second list item. Second list item. Second list item. Second list item. Second list item.
\end{itemize}
As can be seen, the itemize is now separated 30pt from the border of the box.
\end{beamercolorbox}
\end{frame}
\begin{frame}
\begin{beamercolorbox}[sep=30pt]{box}
Some text text text text text text text text text text text text text text
\begin{description}[longest text]
\item[text] First list item. First list item. First list item.
\item[longest text] Second list item. Second list item. Second list item.
\item[more text] Another list item
\end{description}
As can be seen, the description is now separated 30pt from the border of the box.
\end{beamercolorbox}
\end{frame}
\end{document}
