I need to store tikz
option in a \csdef{}
:
\csdef{My Node Option}{draw=red, thick, fill=yellow}
How do I use this definition to define a style via \tikzset
?
I attempted to use .expand once
as per How do I define tikz styles with a xkeyval command?:
\tikzset{Node Options/.style/.expand once=\csuse{My Node Option}}
but that leads to a
Package pgfkeys Error: I do not know the key '/tikz/draw=red, thick, fill=yellow' and I am going to ignore it. Perhaps you misspelled it.
The desired result is to modify only the \tikzset
in the MWE and obtain:
Notes:
- As egreg commented, spaces in names of commands should be avoided. However, in my actual use case, the command names defined by the
csdef{}
are named after file names with paths which include spaces, slashes, numbers, periods.
Code:
\documentclass{article}
\usepackage{tikz}
\usepackage{etoolbox}
\begin{document}
\csdef{My Node Option}{draw=red, thick, fill=yellow}
\noindent
\begin{tikzpicture}
\tikzset{Node Options/.style/.expand once=\csuse{My Node Option}}%% ????
\node [Node Options] at (0,0) {Node Text};
\end{tikzpicture}%
\end{document}
/.expand thrice
, which doesn't exist. But/.expand twice=\csname My Node Option\endcsname
works. I know that spaces in names of commands and options is bad.;-)