[texhax] Can't use \d (dot below) with \edef
Wenlin Institute
wenlin at wenlin.com
Thu Jun 28 16:50:13 CEST 2007
Thank you very much for your help. It's a relief that someone
understands TeX so well and is willing to guide the rest of us
through the double-dangerous bends!
Best wishes,
Tom
On Jun 21, 2007, at 2:04 AM, Oleg Katsitadze wrote:
> 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
> \MacroToBeExpanded happens to start with a digit, that digit would
> 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{.}
>> \advance\dimen0 by -\wd0
>> \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
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
>
> Automated subscription management: http://tug.org/mailman/listinfo/
> texhax
> Human mailing list managers: postmaster at tug.org
>
文林 Wenlin Institute, Inc. Software for Learning Chinese
E-mail: wenlin at wenlin.com Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)
☯
More information about the texhax
mailing list