[tex-live] Nested macro resetting problem

enrico.gregorio at univr.it enrico.gregorio at univr.it
Sun Jun 14 10:55:26 CEST 2009

This is not the right place for this kind of problems; however, here is a different solution.
All commands are defined globally, because an abbreviation's first use in a chapter might
be in a group. You should probably add a meaningful error message

%%% here are the relevant definitions
\newtoks\abbr at list % a hook where we memorize all the definitions
    {\addto at hook\abbr at list{\global\@namedef{#1}/{#2\global\@namedef{#1}/{#1}}}}%
% a patch to the \chapter command, to execute again all the definitions
\edef\chapter{\noexpand\the\abbr at list\the\toks@}
% define the abbreviations for the first time, just to be safe
\AtBeginDocument{\the\abbr at list}
%%% end of the definitions

\newabbr{TUG}{\TeX\ Users Group}
\newabbr{XYZ}{Xy Yz Zu}

\chapter{A title}
\TUG/ is expanded; now \TUG/ is not. The same for \XYZ/ and \XYZ/.
\chapter{A title}
\TUG/ is expanded; now \TUG/ is not. The same for \XYZ/ and \XYZ/.


Enrico Gregorio          + Dipartimento di Informatica          + Tel: +39 045 8027937
Enrico.Gregorio at univr.it + Università degli Studi di Verona     +
(gregorio at math.unipd.it) + Strada le Grazie 15 / I-37134 Verona + Fax: +39 045 8027928

More information about the tex-live mailing list