# Beamer: Change Structure Color in tikzpicture

Why doesn't the following MWE change the color of the latter fill to red? How to fix?

Background: I am changing the structure color for my example frames and want all the tikzpictures within to use colors based on the structure color.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}{My Default Structure Color Rectangle}
\begin{tikzpicture}
\draw [fill=structure] rectangle (2,2);
\end{tikzpicture}
\end{frame}

\setbeamercolor{structure}{fg=red}

\begin{frame}{My Red Rectangle}
\begin{tikzpicture}
\draw [fill=structure] rectangle (2,2);
\end{tikzpicture}
\end{frame}
\end{document}


You have to set \usebeamercolor before actually use it. In addition you should specify .fg while using the color, i.e. structure.fg. This is because while setting \usebeamercolor you also have access to structure.bg, which is a different color.

The code:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}{My Default Structure Color Rectangle}
\begin{tikzpicture}
\draw [fill=structure] rectangle (2,2);
\end{tikzpicture}
\end{frame}

\setbeamercolor{structure}{fg=red}

\begin{frame}{My Red Rectangle}
\usebeamercolor{structure}
\begin{tikzpicture}
\draw [fill=structure.fg] rectangle (2,2);
\draw (4,0) [fill=structure.bg] rectangle+ (2,2);
\end{tikzpicture}
\end{frame}
\end{document}


The result:

• Perhaps change the first fill from structure to structure.fg too? – Mappi Jan 6 '16 at 6:29
• @Mappi: Yes, you should definitely do it. – Claudio Fiandrino Jan 6 '16 at 8:34