ビーマーの定理ブロック幅の変更:Boadillaテーマ

Aug 21 2020

ボアディージャビーマーテーマの定理(または補題など)ブロックの幅をどのように変更しますか?デフォルトのブロックは少し広すぎて、アイテム化の幅と一致しません。図のようにするにはどうすればよいですか?

\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}

回答

muzimuzhiZ Aug 21 2020 at 18:14

このパッチを試してください:

\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}