1

Following the answer to this other question, I am using the Milsymb library and changing the foreground colour.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{forest}
\usepackage{milsymb}

\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} \node (nA) {\tikz{\MilLand[faction=friendly,monochrome,echelon=division,main=armoured]{}}}; \aftercolorof{red}{nA} \end{tikzpicture}

\end{document}

This produces red foregound colour.

enter image description here

How do I also change the node background colour (ie the light grey above, not the white image background)?

Tomas By
  • 187

1 Answers1

1

You can use the fill=... key (please be aware that nesting tikz pictures is not recommended and can have funny side effects.):

\documentclass{standalone}
\usepackage{tikz}
\usepackage{forest}
\usepackage{milsymb}

\begin{document}

\begin{tikzpicture} \node (nA) {\tikz{\pgfsetstrokecolor{red}\MilLand[faction=friendly,monochrome,echelon=division,main=armoured,red,fill=green]{}}}; \end{tikzpicture}

\end{document}

enter image description here

  • 1
    The location key allows positioning without nesting: \coordinate (nA) at (0,0); \pgfsetstrokecolor{red} \MilLand[faction=friendly, echelon=division, main=armoured, red, fill=green](nA). – Jasper Habicht Mar 24 '23 at 19:09
  • It says command undefined when I try \coordinate (and I seem to need the {} at the end, which you have omitted). – Tomas By Mar 24 '23 at 20:06
  • @TomasBy The syntax from @ JasperHabicht works fine for me, no {} at the end. Which error do you get? – samcarter_is_at_topanswers.xyz Mar 24 '23 at 20:08
  • 1
    @JasperHabicht Fun coincidence to meet you at that github repository :) Seems you had the same problem as me while looking into this question :) – samcarter_is_at_topanswers.xyz Mar 24 '23 at 20:10
  • Something about fonts. I was getting one error for each \MilLand (approximately, I had the impression) and they disappeared when I added the brackets. – Tomas By Mar 24 '23 at 20:12
  • Well, I still have the \MilLand commands in the matrix, so that may be the difference. – Tomas By Mar 24 '23 at 20:13
  • @TomasBy \MilLand (and all the other macros defined by the package) have o D(){0,0} d() g as argument type definition, so it is safe (and maybe also necessary sometimes, depending on the context) to add one pair of {} at the end of these macros (if no other argument is given instead). – Jasper Habicht Mar 24 '23 at 20:19
  • @samcarter_is_at_topanswers.xyz Wow, the package author was quick! Maybe we should suggest that they add some way to style the line colors of the symbols ... – Jasper Habicht Mar 24 '23 at 20:23
  • 1
    @JasperHabicht Yes, very quick response! I'm not sure if a way to adjust line colours is that necessary. As far as I understand it, it will adapt to the surrounding text colour, so one can use anything from \color{...} to \pgfsetstrokecolor{...} to change it. – samcarter_is_at_topanswers.xyz Mar 24 '23 at 20:30