Possible Duplicates:
How to submit a set of tikz command with pgfkeys?
Multiple TikZ keys with foreach
I have a class file which is supposed to modify the maketitle. I use TikZ nodes for placement of elements, and wish to add a background for one of the text nodes.
If I add the options directly, everything works fine:
\node [text width=40mm,fill=red] {Foo}
However, since I want to give class users the option to turn the background coloring off, I want to give those node options as a macro, which has a different value depending on class options:
\newcommand\nodefillstyle{fill=red}
\node [text width=40mm,\nodefillstyle] {Foo}
I would expect this to work just as it works elsewhere, but it fails with a confusing error message:
! Package pgfkeys Error: I do not know the key '/tikz/fill=red' and I am going
to ignore it. Perhaps you misspelled it.
Below you can see my class file and .tex file:
test-article.cls:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{test-article}[2013/01/02 My test documentclass]
% Use article default options
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
\RequirePackage{tikz}
\newcommand\nodestyle{fill=red}
\renewcommand\maketitle{%
\begin{tikzpicture}%
\node [text width=40mm,\nodestyle] at (current page.center) {\@title};%
\end{tikzpicture}%
}
simplefill.tex:
\documentclass[a4paper]{test-article}
\title{My title}
\begin{document}
\maketitle
\end{document}
Why does this happen, and how can I achieve using macros within node options?