In TikZ, I'm sometimes in the need to use macros in coordinate names, usually while using \foreach. My problem is that macros in coordinate names eliminate any following spaces.
For example, here is an example of this problem:
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\a{a}
\coordinate (\a 1);
\node at (a1) {Test}; % works correctly
\node at (a 1) {Test}; % error: "No shape named `a 1' is known.
\end{tikzpicture}
\end{document}
In the example I'm using the macro \a in the definition of the coordinate (\a 1). I would expect to get the coordinate (a 1), but the whitespace following the macro is eliminated and I end up with just (a1).
Is there any way to tell TikZ (or LaTeX, I don't really know how the macro expansion works behind the scenes) that I want to keep the space after the macro? I've tried escaping it ((\a\ 1), which doesn't compile), adding more spaces ((\a 1), where any number of spaces still get eliminated) and adding some braces (({\a} 1) or (\a{} 1), which both kind of work to prevent the elimination of the whitespace, but just because the braces are included in the coordinate name, producing ({a} 1) and (a{} 1) respectively).
Is there a solution for my problem or do I just need to avoid using spaces after macros?