I can use the \foreach loop to iterate over an array of strings:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\foreach \v in {A, B}{
\input{the\v file.txt}
}
\end{document}
Now, I would like to compose a string as a macro as in:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand\var{A, B} % <<< macro
\foreach \v in \var{
\input{the\v file.txt}
}
\end{document}
Then I get a problem:
! LaTeX Error: File `theA, Bfile.txt' not found.
Using \def instead of \newcommand creates the same problem using Latex version pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6).
How to solve?
\definstead of\newcommand? – Foitn Jun 12 '18 at 14:34! LaTeX Error: File 'theAfile.txt' not found.and! LaTeX Error: File 'theBfile.txt' not found.which would not occur if those files existed on my system. – Steven B. Segletes Jun 12 '18 at 14:42theA, Bfile.txtif you call\foreach \v in {\var}{...}; not with your code. – egreg Jun 15 '18 at 08:08pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)I have the problem without the braces{. InpdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)I need to add the braces to generate the problem. – Viesturs Jun 15 '18 at 08:49\expandafter\foreach\expandafter i\expandafter n\expandafter{\var}{...}– egreg Jun 15 '18 at 08:57