Latex 如何像beamer中的theoremblocks那样格式化示例块?

Latex 如何像beamer中的theoremblocks那样格式化示例块?,latex,beamer,Latex,Beamer,我想使exampleblocks与theoremblocks一样,具有与theoremblocks相同的格式(除了我希望块标题背景颜色为青色)。我该怎么做?我试着复制粘贴一段代码,这段代码对于定理来说效果很好,并用“示例”替换了“定理”,但没有成功。(我使用\usetheme{Aalborg}) 示例从定理自动继承格式,因此您只需调整颜色: \documentclass{beamer} \usetheme{Aalborg} \uselanguage{danish} \languagepath

我想使exampleblocks与theoremblocks一样,具有与theoremblocks相同的格式(除了我希望块标题背景颜色为青色)。我该怎么做?我试着复制粘贴一段代码,这段代码对于定理来说效果很好,并用“示例”替换了“定理”,但没有成功。(我使用\usetheme{Aalborg})


示例
定理
自动继承格式,因此您只需调整颜色:

\documentclass{beamer}

\usetheme{Aalborg}

\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\deftranslation[to=danish]{Theorem}{Saetning}

\undef{\example}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}


\makeatletter
\setbeamercolor{block title example}{bg=orange,fg=black}
\addtobeamertemplate{block example begin}{}{
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize subitem}{fg=orange!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=orange!100!white}%
  \setbeamercolor{enumerate item}{fg=orange!100!black}%
  \setbeamercolor{enumerate subitem}{fg=orange!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=orange!100!black}%  
}

\setbeamertemplate{theorem begin}{%
  \setbeamercolor{block title}{bg=cyan!100!white}%
  \setbeamercolor{itemize item}{fg=cyan!100!white}%
  \setbeamercolor{itemize subitem}{fg=cyan!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=cyan!100!white}%
  \setbeamercolor{enumerate item}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subitem}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=cyan!100!black}%
  \begin{\inserttheoremblockenv}
    {%
      \inserttheoremname
      \inserttheoremnumber
      \ifx\inserttheoremaddition\@empty\else\ \inserttheoremaddition\fi%
    }%
    \normalfont%
}

\setbeamertemplate{theorem end}{%
    \end{\inserttheoremblockenv}%
}

\makeatother

\begin{document}

\begin{frame}

\begin{theorem}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{theorem}

\begin{example}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{example}


\end{frame} 

\end{document}
\documentclass{beamer}

\usetheme{Aalborg}

\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\deftranslation[to=danish]{Theorem}{Saetning}

\undef{\example}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}


\makeatletter
\setbeamercolor{block title example}{bg=orange,fg=black}
\addtobeamertemplate{block example begin}{}{
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize subitem}{fg=orange!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=orange!100!white}%
  \setbeamercolor{enumerate item}{fg=orange!100!black}%
  \setbeamercolor{enumerate subitem}{fg=orange!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=orange!100!black}%  
}

\setbeamertemplate{theorem begin}{%
  \setbeamercolor{block title}{bg=cyan!100!white}%
  \setbeamercolor{itemize item}{fg=cyan!100!white}%
  \setbeamercolor{itemize subitem}{fg=cyan!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=cyan!100!white}%
  \setbeamercolor{enumerate item}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subitem}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=cyan!100!black}%
  \begin{\inserttheoremblockenv}
    {%
      \inserttheoremname
      \inserttheoremnumber
      \ifx\inserttheoremaddition\@empty\else\ \inserttheoremaddition\fi%
    }%
    \normalfont%
}

\setbeamertemplate{theorem end}{%
    \end{\inserttheoremblockenv}%
}

\makeatother

\begin{document}

\begin{frame}

\begin{theorem}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{theorem}

\begin{example}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{example}


\end{frame} 

\end{document}

示例环境中的颜色仍然与定理环境中的颜色相同(块标题和项目符号的颜色)。此外,示例计数器现在适用于示例和定理,但我希望每个环境都有单独的计数器。@PeterJensen颜色肯定不一样,我添加了一个奇怪的屏幕快照。当我使用提供的代码(复制粘贴)时,定理环境的颜色是可以的,但示例环境的颜色不是。出于某种原因,exampleblock标题的背景色始终为绿色?一个例子中的项目符号的颜色与一个定理中的项目符号的颜色相同。知道怎么回事吗?@PeterJensen因为我的代码中没有
dgreen
,因为在你所有的问题中,你从来没有告诉过使用这种颜色的定义,我怀疑它是完全复制粘贴的。在新文档中尝试与我的答案中完全相同的代码,然后返回报告。当我将完全相同的副本粘贴到新文档中时,我会收到一条错误消息:!未定义的控制序列。1.10\undef{\example}
\documentclass{beamer}

\usetheme{Aalborg}

\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\deftranslation[to=danish]{Theorem}{Saetning}

\undef{\example}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}


\makeatletter
\setbeamercolor{block title example}{bg=orange,fg=black}
\addtobeamertemplate{block example begin}{}{
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize subitem}{fg=orange!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=orange!100!white}%
  \setbeamercolor{enumerate item}{fg=orange!100!black}%
  \setbeamercolor{enumerate subitem}{fg=orange!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=orange!100!black}%  
}

\setbeamertemplate{theorem begin}{%
  \setbeamercolor{block title}{bg=cyan!100!white}%
  \setbeamercolor{itemize item}{fg=cyan!100!white}%
  \setbeamercolor{itemize subitem}{fg=cyan!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=cyan!100!white}%
  \setbeamercolor{enumerate item}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subitem}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=cyan!100!black}%
  \begin{\inserttheoremblockenv}
    {%
      \inserttheoremname
      \inserttheoremnumber
      \ifx\inserttheoremaddition\@empty\else\ \inserttheoremaddition\fi%
    }%
    \normalfont%
}

\setbeamertemplate{theorem end}{%
    \end{\inserttheoremblockenv}%
}

\makeatother

\begin{document}

\begin{frame}

\begin{theorem}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{theorem}

\begin{example}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{example}


\end{frame} 

\end{document}
\documentclass{beamer}

\usetheme{Aalborg}

\uselanguage{danish}
\languagepath{danish}
\deftranslation[to=danish]{Example}{Eksempel}
\deftranslation[to=danish]{Theorem}{Saetning}

\undef{\example}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}


\makeatletter
\setbeamercolor{block title example}{bg=orange,fg=black}
\addtobeamertemplate{block example begin}{}{
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize item}{fg=orange!100!white}%
  \setbeamercolor{itemize subitem}{fg=orange!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=orange!100!white}%
  \setbeamercolor{enumerate item}{fg=orange!100!black}%
  \setbeamercolor{enumerate subitem}{fg=orange!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=orange!100!black}%  
}

\setbeamertemplate{theorem begin}{%
  \setbeamercolor{block title}{bg=cyan!100!white}%
  \setbeamercolor{itemize item}{fg=cyan!100!white}%
  \setbeamercolor{itemize subitem}{fg=cyan!100!white}%
  \setbeamercolor{itemize subsubitem}{fg=cyan!100!white}%
  \setbeamercolor{enumerate item}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subitem}{fg=cyan!100!black}%
  \setbeamercolor{enumerate subsubitem}{fg=cyan!100!black}%
  \begin{\inserttheoremblockenv}
    {%
      \inserttheoremname
      \inserttheoremnumber
      \ifx\inserttheoremaddition\@empty\else\ \inserttheoremaddition\fi%
    }%
    \normalfont%
}

\setbeamertemplate{theorem end}{%
    \end{\inserttheoremblockenv}%
}

\makeatother

\begin{document}

\begin{frame}

\begin{theorem}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{theorem}

\begin{example}[test]
content...
\begin{itemize}
\item test
\end{itemize}
\end{example}


\end{frame} 

\end{document}