我如何要求 beamer 对 \begin{example} 块使用与 begin{theorem} 块相同的颜色?

我如何要求 beamer 对 \begin{example} 块使用与 begin{theorem} 块相同的颜色?

我使用的是华沙主题,一切都很好,只是我不喜欢示例块使用的绿色。我怎样才能将其设置为与定理环境块使用的颜色相同?

这是一个代码示例。

\documentclass[xcolor=dvipsnames]{beamer}

\mode<presentation>
{
  \usetheme{Warsaw}



  \setbeamercovered{invisible}
}

\definecolor{UBCblue}{rgb}{0.04706, 0.13725, 0.26667} % UBC Blue (primary)
\definecolor{UBCgrey}{rgb}{0.3686, 0.5255, 0.6235} % UBC Grey (secondary)

\setbeamercolor{palette primary}{bg=UBCblue,fg=white}
\setbeamercolor{palette secondary}{bg=UBCblue,fg=white}
\setbeamercolor{palette tertiary}{bg=UBCblue,fg=white}
\setbeamercolor{palette quaternary}{bg=UBCblue,fg=white}
\setbeamercolor{structure}{fg=UBCblue} 
\setbeamercolor{section in toc}{fg=UBCblue} 


\setbeamertemplate{blocks}[rounded][shadow=false]
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.8}}{\pgfsetfillopacity{1}}
\setbeamercolor{structure}{fg=UBCblue}


\addtobeamertemplate{navigation symbols}{}{%
    \usebeamerfont{footline}%
    \usebeamercolor[fg]{footline}%
    \hspace{1em}%
    \insertframenumber/\inserttotalframenumber
}

\usepackage[english]{babel}


\usepackage{amsmath, amssymb}
\usepackage{array}
\usepackage{amsthm}
\usepackage{amssymb,amsfonts}  
\usepackage{latexsym} 
\usepackage[all,arc]{xy}
\usepackage{comment}
\usepackage{enumerate}
\usepackage{tikz-cd}
\usepackage{mathrsfs}
\usepackage{rotating}
\usepackage{wasysym}
\usepackage{slashbox}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{sagetex}
\usepackage{mathtools}
\usepackage{stmaryrd}
\usepackage{amstext}

\usepackage{etoolbox}
\usepackage[T1]{fontenc}


\usetikzlibrary{positioning}
\usepackage{stackengine}
\usepackage{filecontents}
\usepackage{color}   %May be necessary if you want to color links
\usepackage{hyperref}
\hypersetup{
    colorlinks=true, %set true if you want colored links
    linktoc=all,     %set to all if you want both sections and subsections linked
    linkcolor=black,
    urlcolor=black,
    citecolor=black,  %choose some color if you want links to stand out
}

\usepackage{xypic}
\usepackage{times}
\usepackage{ulem}
\usepackage[T1]{fontenc}

\newtheorem*{Proposition}{Proposition}
\newtheorem*{keylemma}{Key Lemma}
\newtheorem*{Remark}{Remark}
\newtheorem*{question}{Question}
\newtheorem*{Task}{Task}
\newtheorem*{cor}{Corollary}
\newtheorem*{thm}{Theorem}


\begin{document}

\begin{frame}
\begin{Theorem}
This is a theorem.
\end{Theorem}
\begin{Remark}
This is a remark.
\end{Remark}
\begin{Example}
This is an example. I don't like this color.
\end{Example}
\end{frame}

\end{document}

您将获得输出: enter image description here

答案1

\documentclass{beamer}
\usecolortheme{orchid}

\setbeamercolor{block title example}{use=structure,fg=white,bg=structure.fg!75!black}
\setbeamercolor{block body example}{parent=normal text,use=block title,bg=block title.bg!10!bg}

\begin{document}

\begin{frame}
    \begin{theorem}
  content...
  \end{theorem}

  \begin{example}
  content...
  \end{example}

\end{frame} 

\end{document}

或者使用你问题中不那么简单的例子:

\documentclass[xcolor=dvipsnames]{beamer}

\mode<presentation>
{
  \usetheme{Warsaw}



  \setbeamercovered{invisible}
}

\definecolor{UBCblue}{rgb}{0.04706, 0.13725, 0.26667} % UBC Blue (primary)
\definecolor{UBCgrey}{rgb}{0.3686, 0.5255, 0.6235} % UBC Grey (secondary)

\setbeamercolor{palette primary}{bg=UBCblue,fg=white}
\setbeamercolor{palette secondary}{bg=UBCblue,fg=white}
\setbeamercolor{palette tertiary}{bg=UBCblue,fg=white}
\setbeamercolor{palette quaternary}{bg=UBCblue,fg=white}
\setbeamercolor{structure}{fg=UBCblue} 
\setbeamercolor{section in toc}{fg=UBCblue} 


\setbeamertemplate{blocks}[rounded][shadow=false]
\addtobeamertemplate{block begin}{\pgfsetfillopacity{0.8}}{\pgfsetfillopacity{1}}
\addtobeamertemplate{block example begin}{\pgfsetfillopacity{0.8}}{\pgfsetfillopacity{1}}
\setbeamercolor{structure}{fg=UBCblue}


\addtobeamertemplate{navigation symbols}{}{%
    \usebeamerfont{footline}%
    \usebeamercolor[fg]{footline}%
    \hspace{1em}%
    \insertframenumber/\inserttotalframenumber
}

\usepackage[english]{babel}


\usepackage{amsmath, amssymb}
\usepackage{array}
\usepackage{amsthm}
\usepackage{amssymb,amsfonts}  
\usepackage{latexsym} 
\usepackage[all,arc]{xy}
\usepackage{comment}
%\usepackage{enumerate}
\usepackage{tikz-cd}
\usepackage{mathrsfs}
\usepackage{rotating}
\usepackage{wasysym}
%\usepackage{slashbox}
%\usepackage{graphicx}
\usepackage{tikz}
%\usepackage{sagetex}
\usepackage{mathtools}
\usepackage{stmaryrd}
\usepackage{amstext}

%\usepackage{etoolbox}
\usepackage[T1]{fontenc}


\usetikzlibrary{positioning}
\usepackage{stackengine}
\usepackage{filecontents}
%\usepackage{color}   %May be necessary if you want to color links
%\usepackage{hyperref}
\hypersetup{
    colorlinks=true, %set true if you want colored links
    linktoc=all,     %set to all if you want both sections and subsections linked
    linkcolor=black,
    urlcolor=black,
    citecolor=black,  %choose some color if you want links to stand out
}

\usepackage{xypic}
\usepackage{times}
\usepackage{ulem}
%\usepackage[T1]{fontenc}

\newtheorem*{Proposition}{Proposition}
\newtheorem*{keylemma}{Key Lemma}
\newtheorem*{Remark}{Remark}
\newtheorem*{question}{Question}
\newtheorem*{Task}{Task}
\newtheorem*{cor}{Corollary}
\newtheorem*{thm}{Theorem}


\setbeamercolor{block title example}{use=structure,fg=white,bg=structure.fg!75!black}
\setbeamercolor{block body example}{parent=normal text,use=block title,bg=block title.bg!10!bg}

\begin{document}

\begin{frame}
\begin{Theorem}
This is a theorem.
\end{Theorem}
\begin{Remark}
This is a remark.
\end{Remark}
\begin{Example}
This is an example. I don't like this color.
\end{Example}
\end{frame}

\end{document}

一些评论:

  • 请不要多次加载同一个包

  • 你不需要

    \usepackage{enumerate}
    \usepackage{graphicx}
    \usepackage{etoolbox}
    \usepackage{color}   
    \usepackage{hyperref}
    

    带投影机

相关内容