von esdd » Do 21. Jul 2016, 12:01
Wenn Du eine matrix of nodes verwendest, dann werden die einzelnen Zellen als Nodetext betrachtet und in diesem ist der Befehl \node nicht definiert. Der Befehl \robGbase funktioniert, weil (Zitat aus der Doku)
If your cell starts with a \path command or any command that expands to \path, which includes \draw, \node, \fill and others, the \node{ startup code and the }; code are suppressed. This means that for this particular cell you can provide totally different contents.
Fügst Du am Anfang von \robG ein \path; ein, dann funktioniert es auch dafür.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{ifthen}
\newcommand{\robGbase}[2]{%
\node [fill=#1,circle,inner sep=0em,radius=0.5em] {#2};
}
\newcommand{\robG}[1]{%
\path;% <- eingefügt
\ifthenelse{ \equal{#1}{+} }
{\robGbase{green}{+}}
{%
\ifthenelse{ \equal{#1}{-} }
{\robGbase{red}{-}}
{% else
}
}
}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes]
{
A & \robGbase{green}{+} \\
B & \robG{+} \\
};
\end{tikzpicture}
\end{document}
Wenn Du eine [tt]matrix of nodes[/tt] verwendest, dann werden die einzelnen Zellen als Nodetext betrachtet und in diesem ist der Befehl [tt]\node[/tt] nicht definiert. Der Befehl [tt]\robGbase[/tt] funktioniert, weil (Zitat aus der Doku)
[quote] If your cell starts with a \path command or any command that expands to \path, which includes \draw, \node, \fill and others, the \node{ startup code and the }; code are suppressed. This means that for this particular cell you can provide totally different contents.[/quote]
Fügst Du am Anfang von [tt]\robG[/tt] ein [tt]\path;[/tt] ein, dann funktioniert es auch dafür.
[code]\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{ifthen}
\newcommand{\robGbase}[2]{%
\node [fill=#1,circle,inner sep=0em,radius=0.5em] {#2};
}
\newcommand{\robG}[1]{%
\path;% <- eingefügt
\ifthenelse{ \equal{#1}{+} }
{\robGbase{green}{+}}
{%
\ifthenelse{ \equal{#1}{-} }
{\robGbase{red}{-}}
{% else
}
}
}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes]
{
A & \robGbase{green}{+} \\
B & \robG{+} \\
};
\end{tikzpicture}
\end{document}[/code]