投影仪中不同类型的块有不同的颜色

投影仪中不同类型的块有不同的颜色

在 beamer 演示中,我想为普通块、定义块、定理块、证明块、示例块设置不同的颜色……

理想情况下,我会使用命令来设置它们\usebeamercolor。我可以为示例块执行此操作,也可以同时为所有其他类型的块执行此操作,如下面的示例所示(使用 XeLaTeX 编译)。但我找不到如何为特定的非示例类型的块执行此操作。

我想 ”定制投影机模块的优缺点“指向一些解决方案,但我更喜欢(以某种方式)从现有的特殊块环境定义继承,而不是从头开始定义新的环境。

\documentclass{beamer}
\usepackage{fontspec}

\useinnertheme[shadow=true]{rounded}

\setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
\setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg}

\setbeamercolor{block title example}{use=example text,fg=example text.fg,bg=example text.fg!20!bg}
\setbeamercolor{block body example}{parent=normal text,use=block title example,bg=block title example.bg!50!bg}

\begin{document}
\begin{frame}
    \begin{block}{My block}
        A block.
    \end{block}
    \begin{definition}[My definition]
        A definition.
    \end{definition}
    \begin{theorem}[My theorem]
        A theorem.
    \end{theorem}
    \begin{proof}[My proof]
        A proof.
    \end{proof}
    \begin{example}[My example]
        An example.
    \end{example}
\end{frame}
\end{document}

答案1

\documentclass{beamer}

\useinnertheme[shadow=true]{rounded}

\usepackage{etoolbox}

\setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
\setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg}

\setbeamercolor{block title example}{use=example text,fg=example text.fg,bg=example text.fg!20!bg}
\setbeamercolor{block body example}{parent=normal text,use=block title example,bg=block title example.bg!50!bg}

\addtobeamertemplate{proof begin}{%
    \setbeamercolor{block title}{fg=black,bg=red!50!white}
    \setbeamercolor{block body}{fg=red, bg=red!30!white}
}{}

\BeforeBeginEnvironment{theorem}{
    \setbeamercolor{block title}{fg=black,bg=orange!50!white}
    \setbeamercolor{block body}{fg=orange, bg=orange!30!white}
}
\AfterEndEnvironment{theorem}{
 \setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
 \setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg, fg=black}
}

\BeforeBeginEnvironment{definition}{%
    \setbeamercolor{block title}{fg=black,bg=pink!50!white}
    \setbeamercolor{block body}{fg=pink, bg=pink!30!white}
}
\AfterEndEnvironment{definition}{
 \setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
 \setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg, fg=black}
}

\begin{document}
\begin{frame}
    \begin{block}{My block}
        A block.
    \end{block}

    \begin{definition}[My definition]
        A definition.
    \end{definition}

    \begin{theorem}[My theorem]
        A theorem.
    \end{theorem}
    \begin{proof}[My proof]
        A proof.
    \end{proof}
    \begin{example}[My example]
        An example.
    \end{example}

    \begin{block}{My block}
        A block.
    \end{block}    

\end{frame}
\end{document}

在此处输入图片描述

相关内容