Am posting two in one as I suspect these may be related. Following on from my previous question, I am putting them in a matrix:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{milsymb}
\usetikzlibrary{matrix}
\makeatletter
\protected\def\tikz@fig@main#1{%
\expandafter\gdef\csname labeltextof@\tikz@fig@name\endcsname{#1}%
\iftikz@node@is@pic%
\tikz@node@is@picfalse%
\tikz@subpicture@handle{#1}%
\else%
\tikz@@fig@main#1\egroup%
\fi}
\makeatother
\newcommand\labeltextof[1]{\csname labeltextof@#1\endcsname}
\newcommand{\aftercolorof}[2]{% #1 is the color, #2 us the node
\path (#2.center) node[#1] (#2-2) {\labeltextof{#2}};
}
\begin{document}
\begin{tikzpicture}
\matrix[row sep=2mm, column sep=1mm]{
\node (nA) {\tikz{\MilLand[faction=friendly,monochrome,echelon=division,main=armoured,fill=green]{}}};
\node (nA) {\tikz{\MilLand[faction=friendly,monochrome,echelon=division,main=armoured,fill=yellow]{}}};
&
\node (nA) {\tikz{\MilLand[faction=friendly,monochrome,echelon=division,main=armoured,fill=green]{}}};
\node (nA) {\tikz{\MilLand[faction=friendly,monochrome,echelon=division,main=armoured,fill=yellow]{}}};
\\
};
%\aftercolorof{red}{nA}
\end{tikzpicture}
\end{document}
This produces an error at the end of the matrix:
! Undefined control sequence.
<argument> \pgf@matrix@last@nextcell@options
l.33 }
;
? x
And if I try to remove the inner \tikz
command, as suggested in the answer to the linked question, I get another error:
! LaTeX Error: Environment scope undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.25 ...elon=division,main=armoured,fill=green]{}}
;
?
There is a third problem also, that the echelon symbol (ie XX for division) is put too far away vertically. This seems to happen only in matrix.
Any ideas anybody?
tikzpicture
inside anothertikzpicture
. The\tikz{...}
command is just a shortcut for\begin{tikzpicture}...\end{tikzpicture}
. I strongly recommend rewriting the code to avoid this nesting (here and in the previous question).