# normalcolor not working with tikz

In the following MWE

\documentclass{article}
\usepackage{tikz}
\begin{document}

\color{gray}
Gray point $$X$$
$A = B$

\normalcolor
Black point $$Y$$
$C = D$

\begin{tikzpicture}
\node at (0,0) {Test};
\end{tikzpicture}
\end{document}


I use the \color command to change the color to gray and \normalcolor to change back to the default color. This works for text and equations but not for nodes in tikzpicture for some reason. I expected the default color in tikzpictures to change back to black.

Is this behavior expected? How can I reset the default color of tikz?

I know that I can surround the \color statement with a \begingroup -- \endgroup, but I don't want to do that because adding groups breaks things in my particular application.

As Ulrike Fisher points out in a comment below, it is a bug in xcolor (its definition of \normalcolor is faulty, it doesn't update the . color.).

Here is a workaround:

\documentclass{article}
\usepackage{tikz}
\AtBeginDocument{\colorlet{normalcolor}{.}\def\normalcolor{\color{normalcolor}}} % workaround
\begin{document}

\color{gray}
Gray point $$X$$
$A = B$

\normalcolor
Black point $$Y$$
$C = D$

\begin{tikzpicture}
\node at (0,0) {Test};
\end{tikzpicture}
\end{document}

• it is not a bug in tikz but in xcolor. Its definition of \normalcolor is faulty, it doesn't update the . color. Aug 6, 2021 at 17:47
• @UlrikeFischer Thanks for this information. Aug 7, 2021 at 5:52