使用投影仪颜色

使用投影仪颜色

为了避免颜色过多,我使用 beamer 的颜色来强调文本中的元素。它看起来就像这样:

\documentclass[xcolor=dvipsnames]{beamer} 
\usetheme{Madrid}

\newcommand{\gn}[1]{\textcolor{block title example.bg}{{}#1{}}}

\begin{document}

  \begin{frame}{Green text}
  \gn{This isn't working.}

  \begin{example}[boring example]

    nothing to see here.
    \end{example}

  \gn{This is green.}

  This is black.
  \end{frame}
  \end{document}

现在,如果我尝试在 beamer 第一次使用该颜色之前使用它(如“这不起作用”),我会收到错误:

Package xcolor Error: Undefined color `block title example.bg'.

有办法解决这个问题吗?

答案1

\usebeamercolor[bg]{block title example}将使用颜色

\documentclass[xcolor=dvipsnames]{beamer} 
\usetheme{Madrid}

\newcommand{\gn}[1]{{\usebeamercolor[bg]{block title example}#1}}

\begin{document}

  \begin{frame}{Green text}
  \gn{This isn't working.}

  \begin{example}[boring example]

    nothing to see here.
    \end{example}

  \gn{This is green.}

  This is black.
  \end{frame}
  \end{document}

相关内容