Please consider the following dummy MWE:
\documentclass[border=3mm,tikz,preview]{standalone}
\usetikzlibrary{arrows,positioning,shadows,shapes}
\tikzset{test/.style = {%
> = angle 90,
YY/.style args = {##1/##2/##3}{
% changed in each use of shape
name=n##1,
% different in each picture
fill=##2,% color
text width=##3,
% common in each picture
shape=rectangle, draw, inner sep=1mm, minimum height=9mm,
align=flush center, drop shadow}, }
}
\begin{document}
\begin{tikzpicture}[test,
node distance = 12mm,
]
\node[YY=1/white/12mm] {node A};
\node[YY=2/white/12mm,right=of n1] {node B};
\draw[->] (n1) -- (n2);
\end{tikzpicture}
\end{document}
Is it possible to set optional parameters #2
and #3
as default in some picture and then change only parameter #1
on the following way:
\node[YY=1] {node A};
\node[YY=2,right=of n1] {node B};
\draw[->] (n1) -- (n2);
I'm aware of possibilities of `YY/.default = 1/white/12mm, but it has sense only if the all nodes have the same name (in considered dummy case). Then ones can write:
\node[YY] {node A};
\node[YY,right=of n1] {node B};
In this case the names can be put in (...)
after node declaration, but this in the case, that node has defined node contents
is not possible ...
Edit:
My main intention is to make node description (determining parameters) as well presets in each TikZ picture as short as possible and for one, who aware of defined presets, make it intuitive. In this I wonder, if it is possible to define optional parameters on similar way as can be defined for example \newcommand
in LaTeX:
\newcommand{maycomand}[2][optional parameter] {command definition};
In sense of my (dummy) example in the case, that node use preset parameters, the node declaration is
\node[YY=1] {node content};
and in the case, when I like to change default optional values, I can simple write:
\node[YY=1/red!20/22mm] {node content};
So far (for simplified case of given MWE) I can do the following:
as say @cfr in his comment (and I was not aware before) in node preset determine only option
#2
and#3
and name of node write in braces like:\node (name) [YY] {node contents};
when I use default values for optional parameters, and\node (name) [YY=red!20/22mm] {node contents};
when I change default values.not use optional arguments in node preset and in each picture add in its preamble
YY/.append style = {fill=white, text width=12mm}
and in case, that I like to have different color and width, this locally overwrite as\node[YY=name,fill=red!20,text width=22mm] {node content};
center
andflush center
, by the way? I've never seen this before...flush center
see manual, section 17.4.3 on pp. 224 (bottom, in CVS version of TikZ).flush center
suppress hyphenation, onlycenter
not.\node (name) [YY]
? But, in any case, I still don't really see what the problem is. Why are you set onYY/.style args ={thing/thing/thing}
? Why that syntax given that it then means you need to specify 3 args?