3

I'm trying to use the beamer system colours for tikz pictures, and I try to follow the approach from this post:

How to get actual values of colour theme colours in beamer?

So what I came up with is this:

\documentclass[xcolor=dvipsnames]{beamer} 
\usetheme{Madrid}
\usebeamercolor{block body alerted}\definecolor{lred}{named}{bg}
\usebeamercolor{alerted text}\definecolor{dred}{named}{fg}
\usebeamercolor{structure}\definecolor{dblue}{named}{fg}
\usebeamercolor{block body}\definecolor{lblue}{named}{bg}
\usebeamercolor{block title example}\definecolor{dgreen}{named}{bg}
\usebeamercolor{block body example}\definecolor{lgreen}{named}{bg}

\begin{document}

  \begin{frame}{colourful text}


    \LARGE
    \textcolor{lred}{light red}
    \textcolor{dred}{dark red}

    \textcolor{lblue}{light blue}
    \textcolor{dblue}{dark blue}

    \textcolor{lgreen}{light green}
    \textcolor{dgreen}{dark green}

  \end{frame}
  \end{document}

Strange enough, it works for some colors, but not for "light green" and "light blue".

What am I doing wrong?

Edit: using the colour names directly, as in

 \draw[fill=block body alerted.bg] (0,-.25) ellipse (6cm and 3cm);

only works after there has been an alert block in the document, and it is a lot of typing work if you use the colors often.

1 Answer 1

3

The block body example color is defined in a bit curious way. It refers to a bg color and so to a previous color. It looks as if it more or less expects that the normal color has been called first. You can force this by using the *-version of the command:

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

\usebeamercolor{block body alerted}\definecolor{lred}{named}{bg}
\usebeamercolor{alerted text}\definecolor{dred}{named}{fg}
\usebeamercolor{structure}\definecolor{dblue}{named}{fg}
\usebeamercolor{block body}\definecolor{lblue}{named}{bg}
\usebeamercolor{block title example}\definecolor{dgreen}{named}{bg}
\usebeamercolor*{block body example}\definecolor{lgreen}{named}{bg}
\begin{document}

  \begin{frame}{colourful text}

    \LARGE
    \textcolor{lred}{light red}
    \textcolor{dred}{dark red}

    \textcolor{lblue}{light blue}
    \textcolor{dblue}{dark blue}

    \textcolor{lgreen}{light green}
    \textcolor{dgreen}{dark green}
   \end{frame} 
  \end{document}
1
  • Thanks! I never would have figured that out...
    – Jan
    Commented Aug 18, 2019 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .