I want to set the fill-color of a rectangle depending on a number stored in a counter. This is my try:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\background}[1]{%
\begin{tikzpicture}[overlay,remember picture]
\fill [#1]
($ (current page.north west) + (.7cm,-.7cm) $)
rectangle
($ (current page.south east) + (-.7cm,.7cm) $);
\end{tikzpicture}
}
\newcounter{test}
\setcounter{test}{1}
\newcommand{\chooseColor}{\ifnum\thetest=1 green \else red \fi}
\begin{document}
\background{green} % everything is good
\newpage
\background{\chooseColor} % throwing the error shown below
\end{document}
Whilst \background{green}
yields what I'm looking for, \background{\chooseColor}
throws the following Error:
! Package pgfkeys Error: I do not know the key '/tikz/green ' and I am going to
ignore it. Perhaps you misspelled it.
I conclude from the error, that \background{\chooseColor}
has been evaluated to 'green' correctly, however I get that error message. Is there anything I missed out on this one? I will be glad for every help!