I have a problem with a macro-defined list in a TikZ foreach loop. The macro is built by \csname
...\endcsname
.
I've played around with multiple \expandafter
or ##1 instead of #1, but with no success: The list of elements is not considered as of multiple elements then as a complete string.
Here is my MWE:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
% Macro to read in configuration parameters
\newcommand*\ReadCfg[3]{%
\expandafter\xdef\csname#1#2list\endcsname{#3}%
}
% Provide list for upper positions (this macro will be looped by \foreach)
% \jobname is 'AUT'
\providecommand\ListUpper{%
\expandafter\csname\jobname upperlist\endcsname%
}
% This configuration will be later provided by external file
\ReadCfg{AUT}{upper}{Elem1,Elem2,Elem3}
\begin{document}
\begin{tikzpicture}
\foreach \e in \ListUpper {
\typeout{***\space\e} % \e is interpreted as "Elem1,Elem2,Elem3" instead of single elements
}
\end{tikzpicture}
\end{document}
So, how can I loop throu the list of elements?
Thank you!
\ListUpper
->\expandafter\csname ...
->\documentupperlist
->Elem1,Elem2,Elem3
). So you'll need to do a bit of pre-processing to shorten that sequence. Will your list contain macros itself or will it be just strings? If the latter, simplest might be to do a\edef\ListUpper{...}
just before the\foreach
. It depends slightly on how automated you want it to be.