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)?

0

1 Answer 1

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

9
  • 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). Mar 24, 2023 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, 2023 at 20:06
  • @TomasBy The syntax from @ JasperHabicht works fine for me, no {} at the end. Which error do you get? Mar 24, 2023 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 :) Mar 24, 2023 at 20:10
  • 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. Mar 24, 2023 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .