Modifica della larghezza del blocco del teorema in beamer: tema di Boadilla

Aug 21 2020

Posso chiederti come si modifica la larghezza del blocco del teorema (o del lemma, ecc.) Nel tema Boadilla Beamer? Il blocco predefinito è un po 'troppo largo e non corrisponde alla larghezza dell'oggetto. Come posso fare qualcosa come mostrato nella figura?

\documentclass[9pt]{beamer}
\usefonttheme{serif}
\usepackage[english]{babel}


\usetheme{Boadilla}


\begin{document}

\begin{frame}{A Lemma and a Theorem}{}
    \begin{itemize}
        \item This is one lemma and one theorem:
    \end{itemize}
    \begin{lemma}[Name of Lemma 1]
        Lemma
        \begin{equation}
        x + y = z
        \end{equation}
    \end{lemma}
    \begin{theorem}[Name of Theorem 1]
        \begin{equation}
        x - z = w
        \end{equation}
    \end{theorem} 
\end{frame}


\end{document}

Risposte

muzimuzhiZ Aug 21 2020 at 18:14

Prova questa patch:

\documentclass[9pt]{beamer}
\usefonttheme{serif}
\usepackage[english]{babel}

\usetheme{Boadilla}

\usepackage{xpatch}

\newlength{\thmwidth}
\setlength{\thmwidth}{0.85\textwidth}

\makeatletter
% patch beamer template "block begin"
\expandafter\xpatchcmd\csname beamer@@tmpl@block begin\endcsname
  {\begin{beamerboxesrounded}[}
  {%
    \hspace*{\dimexpr .5\textwidth-.5\thmwidth}% insert left skip
    \begin{beamerboxesrounded}[width=\thmwidth,% set width
  }
  {}{\fail}
\makeatother

\begin{document}

\begin{frame}{A Lemma and a Theorem}{}
    \begin{itemize}
        \item This is one lemma and one theorem:
    \end{itemize}
    \begin{lemma}[Name of Lemma 1]
        Lemma
        \begin{equation}
        x + y = z
        \end{equation}
    \end{lemma}
    \begin{theorem}[Name of Theorem 1]
        \begin{equation}
        x - z = w
        \end{equation}
    \end{theorem} 
\end{frame}

\end{document}