I am writing a report that includes enzyme images such as this:
In the \caption I would like to include a colour guide so that key components/atoms can be described in colour (this report is not being published so with respect to colour blindness this is not an issue). I am currently using a command like this:
\newcommand\ColourGuide{%
Colour code: \textcolor{violet}{metal ion}, \textcolor{Green3}{residue}, \textcolor{teal}{ligand}, \textcolor{Yellow3}{substrate}, \textcolor{DarkOrange1}{phosphorus}, \textcolor{red}{oxygen} and \textcolor{RoyalBlue4}{nitrogen}%
}
However, with some images not all of the coloured components are present so it would not be good to include redundant colour codes. How can I create a sentence based upon input? For example:
\ColourGuide{M}{R}{S}{O}{N}
would produce:
Colour code: metal ion, residue, substrate, oxygen and nitrogen.
in the colours specified. I am using lualatex and looked at using lua (which would be nice) but I do not know how to interact the two properly (nor efficiently), how could the arguments be extracted for example like in Python with input[0]? I would appreciate any advice or solutions via any method but lua would be nice so I can start learning it and applying it to other commands, I use lualatex frequently.
MWE:
\documentclass{book}
\usepackage[x11names]{xcolor}
\newcommand\ColourGuide{%
Colour code: \textcolor{violet}{metal ion}, \textcolor{Green3}{residue}, \textcolor{teal}{ligand}, \textcolor{Yellow3}{substrate}, \textcolor{DarkOrange1}{phosphorus}, \textcolor{red}{oxygen} and \textcolor{RoyalBlue4}{nitrogen}%
}
\begin{document}
\ColourGuide{}
\end{document}
How it looks:
(I am not sure what tags to put on this)





\ColourGuide{MRSON}and pull off the letters one at a time. – John Kormylo Mar 01 '23 at 14:55and #1.. I would appreciate if there is an existing answer like that I cannot find one – JamesT Mar 01 '23 at 15:26