7

How might it be possible to change the font color of a tikzpicture element to the value of a particular beamercolor, e.g. block title?-- For example:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\frame{
\begin{tikzpicture}
    \draw (0, 5) node (n1) [text=block title] {I should be the same color as block text.};
    \draw (0, 0) node (n2) {I should be plain black text.};
    \path (n1) edge (n2);
\end{tikzpicture}
} 

\end{document}

1 Answer 1

6

You can use font={\usebeamercolor[fg]{block title}}. The reason for using font here is that \usebeamercolor as I understand it essentially inserts a \color{<color name>}, so you cannot use it as a colour name directly.

enter image description here

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\frame{
\begin{tikzpicture}
    \draw (0, 5) node (n1) [font={\usebeamercolor[fg]{block title}}] {I should be the same color as block text.};
    \draw (0, 0) node (n2) {I should be plain black text.};
    \path (n1) edge (n2);
\end{tikzpicture}
} 

\end{document}
3
  • Thanks. Have you got any recommendation on how I can incorporate usage of this macro inside the text label with overlays a la using PGF keys, e.g. so that I should be the same color as block text is "block text" color only on a given slide? Commented May 22, 2016 at 18:26
  • @errantlinguist No tricks needed there, did you try? I tested with the code Matthew Leingang posted, and adding for example onslide=<2>{font=\usebeamercolor[fg]{block title}} as a node option works as expected. Commented May 22, 2016 at 18:32
  • actually, that was in fact a lot less painful than I thought it'd be! Commented May 22, 2016 at 18:35

You must log in to answer this question.

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