4

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.

enter image description here

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

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:

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.