I need a macro, which saves a string (like the content of a label) to the aux file. During the next run, there should be a macro checking, if that string has been set in the last run or not.
My solution so far presented as an example:
\documentclass{minimal}
\usepackage{etoolbox}
\makeatletter
\def\csxdefaux#1{%
\protected@write\@mainaux{}{%
\expandafter\string\expandafter\xdef\expandafter\string\csname #1\endcsname{}%
}%
}
\makeatother
\begin{document}
\ifcsdef{setValue}{value set}{value \emph{not} set}
\csxdefaux{setValue}
\ifcsdef{strange:value}{strange value set}{strange value \emph{not} set}
\csxdefaux{strange:value}
\end{document}
This results (after multiple compilations) in:

So although the pair of \csxdefaux and \ifcsdef macros obviously works for normal strings, it fails for strings with special characters.
What would be a good way to achieve the same as with my solution but supporting a wide range of special characters like colons, digits, umlauts?
\xdefis not needed in this simple example, it was a relic of a more complex use case. – Patrick Häcker Jul 22 '12 at 19:10