I am running into problem when using a color in TikZ which I have predefined using conditionals. The message I get is
In the minimal example below, the first call to TikZ works fine, but not the second. I tried using {...} but it doesn't seem to do anything.Package pgfkeys Error: I do not know the key '/tikz/ green ' and I am going t
o ignore it. Perhaps you misspelled it.
Code: Select all
\documentclass{minimal}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\def\mycolor#1{\ifnum#1=0
green
\else
red
\fi
}
\def\somecolor{green}
\tikz \fill[\somecolor](0,0) rectangle (1,1);
\tikz \fill[\mycolor0](0,0) rectangle (1,1);
\end{document}