2

The following does not work in tikz/math :

\documentclass[tikz]{standalone}
\usetikzlibrary{math}
\begin{document}
\tikzmath
{
  let \a = my black string ;
  let \b = my red string ;
  let \c{1} = \a{\noexpand\color{red}\b}\a;
  print{\c{1}};
}
\end{document}

even though it will upon replacing all instances of \c{1} by \c.

Some way to still do that for associative arrays ?

Cheers,

1
  • There are several and more robust ways for doing such jobs. I mean, without \tikzmath.
    – egreg
    Oct 22, 2016 at 8:06

1 Answer 1

1

It's a followup question. Apparently \edef is used more often and \noexpand gots consumed, exposing \color again. A better way is therefore to use a robust definition made via e-TeX's \protected\def. Package etoolbox provides an interface via \robustify:

\documentclass[tikz]{standalone}
\usetikzlibrary{math}

\usepackage{etoolbox}
\robustify\color

\begin{document}
\tikzmath
{
  let \a = my black string ;
  let \b = my red string ;
  let \c{1} = \a{\noexpand\color{red}\b}\a;
  print{\c{1}};
}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.