使用投影機顏色

使用投影機顏色

為了避免顏色過多,我使用投影機的顏色來強調文字的項目。它看起來像這樣:

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

現在,如果我嘗試在投影機第一次使用顏色之前使用它(如“這不起作用”),我會收到錯誤:

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}

相關內容