We can define a variable and pass it to a module using
\pgfmathsetmacro\j{6}
Which it means j=6, How can I define a variable for a color, I mean I want to pass color to a module
\pgfmathsetmacro\colr{white}
But I encountered Unknown function 'white'. How can I solve it?!
I have the below code
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{appendix}
\usepackage{array,textcomp}
\usepackage[latin1]{inputenc}
\usetikzlibrary{bayesnet}
\usetikzlibrary{positioning}
\usepackage{color}
\usepackage{caption}
\pgfmathsetseed{5}
\makeatletter
\DeclareRobustCommand{\rvdots}{%
\vbox{
\baselineskip4\p@\lineskiplimit\z@
\kern-\p@
\hbox{.}\hbox{.}\hbox{.}
}}
\makeatother
\tikzset{main/.style={circle, minimum size = .1cm, thick, draw =black!80, node distance = 3mm},
connect/.style={-latex, thick},
box/.style={rectangle, draw=black}
}
\begin{document}
\begin{tikzpicture}[lds/.pic={j=#1,colr=#2,%<----- here is the variable
\node[box,draw=\colr] (-Latent) {};
\node[main,minimum size=.2cm, right=of -Latent] (-L1) {$x_1^{(\j)}$};
\node[main,minimum size=.2cm] (-L2) [right=of -L1] {$x_2^{(\j)}$};
\node[main,minimum size=.2cm] (-Lt) [right=5mm of -L2] {$x_T^{(\j)}$};
\node[box,draw=white!100] (-Observed) [below=of -Latent] {};
\node[main,fill=black,text=white,minimum size=.2cm] (-O1) [right=of -Observed,below=of -L1] {$y_1^{(\j)}$};
\node[main,fill=black,text=white,minimum size=.2cm] (-O2) [right=of -O1,below=of -L2] {$y_2^{(\j)}$};
\node[main,fill=black,text=white,minimum size=.2cm] (-Ot) [right=of -O2,below=of -Lt] {$y_T^{(\j)}$};
\draw (-L1.east) edge [connect] (-L2);
\node at (16,0) {$\dots$};
\path (-L1.south) edge [connect] (-O1);
\path (-L2.south) edge [connect] (-O2);
\path (-Lt.south) edge [connect] (-Ot);
},my text/.style={rounded corners=2pt, text width=10mm, font=\sffamily, line width=.5pt, align=left},
my arrow/.style={rounded corners=2pt, draw=green!15, line width=1.5mm, -{Triangle[]}}]
\pgfmathsetmacro\j{6}
\def\colr{white} %<----here
\pic(lds1) at (0,7){lds};
\end{tikzpicture}
\end{document}

\def\colr{white}? – Henri Menke Jan 09 '17 at 17:00\colr? The\defshould work in most cases... You may also try\colorletif you are trying to define colors resulting from mixings. – JLDiaz Jan 09 '17 at 17:12