Suppose I want to write the following to the .aux
-file
\gdef\hello{\world\foobar}
And I do it this way:
\documentclass{article}
\makeatletter
\def\auxdef#1#2{
\immediate\write\@auxout{\string\gdef\string#1{\unexpanded{#2}}}
}
\makeatother
\begin{document}
\def\world{world}
\def\foobar{foo bar}
\auxdef\hello{\world\foobar}
\ifcsname hello\endcsname%
\hello
\else%
not set yet
\fi
\end{document}
Then running pdflatex
once and checking the .aux
-file, it shows:
\relax
\gdef\hello{\world \foobar }
There are now two spaces that I didn't explicitly insert anywhere: one between \world
and \foobar
and another one betwenn \foobar
and }
.
The questions are: where does the spaces come from? How can they be removed?