One of my current tasks involves composing an auxiliary file with extra commands to be loaded at a separate compilation. Here's an MWE:
\documentclass{memoir}
\newwrite\testaux
\immediate\openout\testaux=\jobname.myaux
\begin{document}
\makeatletter
\immediate\write\testaux{\noexpand\dont@want@spaces@after@this words}
\immediate\write\testaux{\unexpanded{\dont@want@spaces@after@this@either}words}
\makeatother
Here is a body.
\end{document}
This produces a .myaux
file with these contents:
\dont@want@spaces@after@this words \dont@want@spaces@after@this@either words
I do not understand why both e-TeX macros put a space after their "expansion." What do I do to write this?
\dont@want@spaces@after@thiswords \dont@want@spaces@after@this@eitherwords
\string
the space is there so that the token will be read back as it is written, if tex did not add a space the tokenization when read back is completely different\string
works ... answer?\noexpand
is defined, so you can simply type\immediate\write\testaux{\noexpand\dont@want@spaces@after@thiswords}
The space is added exactly for preventing wrong interpretation when the file is read back in.