# [texhax] Can't use \d (dot below) with \edef

Thu Jun 21 11:04:06 CEST 2007

On Wed, Jun 20, 2007 at 01:52:28PM -0700, Wenlin Institute wrote:
> I'm copying \firstmark or \botmark or \splitbotmark, which
> subsequently changes. I need to save the current value before it
> changes.

Then the problem is (I suspect) in \mark's expansion of \d.  To avoid
that, you can use the trick with the toks registers:

\toks0={\d{u}}
\mark{\the\toks0}

Here, \mark will substitute the contents of \toks0, without any
further expansion.

You can save the marks like this:

\expandafter\def\expandafter\savedfirstmark\expandafter{\firstmark}

or equivalently, but requiring a token register

\toks0=\expandafter{\firstmark}
\edef\savedfirstmark{\the\toks0}

Here again we avoid unnecessary expansion of the mark's contents.  If
you need more complex definition of \savedfirstmark, you can again use
the combination of \edef, \toks and \noexpand, for example:

\edef\savedfirstmark{\noexpand\MacroNotToBeExpanded \the\toks0 \MacroToBeExpanded}%
^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^  ^^^^^^^^^^^^^^^^^
no expansion      one-level    full expansion
expansion

Note the space after \toks0 -- this delimits the token register's
number and is removed from the input (doesn't make it into
\savedfirstmark's definition).  Without the space, if
become part of the token register's number.

> In the meantime, I found a
> workaround which was to redefine \d without \halign:
>
> \def\d#1{\leavevmode\setbox0=\hbox{#1}\dimen0=\wd0\setbox0=\hbox{.}
> 	\hbox{#1\raise-0.5ex\hbox to 0pt{\hss.\kern.5\dimen0}}}%

This works around this particular problem, but similar problems are
bound to crop up later on, so it's better to fix the cause of the
problem.

> Thank you also for your explanations

You're welcome :).

Cheers,
Oleg