[tex-live] Nested macro resetting problem

Geoff Russell geoffrey.russell at gmail.com
Sun Jun 14 01:15:37 CEST 2009


Hi Zdenek,

Thanks for a simple and elegant solution ... what I had in mind was far more
complex!

Cheers,
Geoff

On 6/14/09, Zdenek Wagner <zdenek.wagner at gmail.com> wrote:
> Hi Geoffrey,
>  the easiest way is probably making use of grouping. Try the following
>  file, it shows different aspects. Notice that the macros must be
>  \protect'ed in moving arguments.
>
>  \documentclass{book}
>  \def\newabbr#1#2{\expandafter\def\csname #1\endcsname
>
>     {#2 (#1)\expandafter\def\csname #1\endcsname{#1}}}
>
>
> \newabbr{TUG}{\TeX\ Users Group}
>  \begin{document}
>  \tableofcontents
>  \begin{chapter}{The first chapter}
>  \TUG
>
>  \TUG
>  \end{chapter}
>
>  \begin{chapter}{Another chapter}
>  \TUG
>
>  \TUG
>  \end{chapter}
>
>  \begin{chapter}{Another chapter on \protect \TUG}
>  \TUG
>
>  \TUG
>  \end{chapter}
>
>  \begin{chapter}[The Last chapter]{\protect\TUG}
>  \TUG
>
>  \TUG
>  \end{chapter}
>
>  \begin{chapter}{\protect\TUG\ again}
>  \TUG
>
>  \TUG
>  \end{chapter}
>
>  \begin{chapter}*{Do not put me into toc}
>  \TUG
>
>  \TUG
>  \end{chapter}
>  \end{document}
>
>  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>  2009/6/13 Geoff Russell <geoffrey.russell at gmail.com>:
>
> > When writing I like to put the full name of an organisation at the
>  > first reference
>  > and its initials subsequently:
>  >
>  > e.g., The TeXLive User Group (TUG) is always helpful in solving my
>  > problems, because
>  > TUG people are smarter than the average bear.
>  >
>  > So I want to say:  The \TUG/ is always helpful in solving my problems
>  > because \TUG/ people are smarter than the average bear.
>  >
>  > Easy,
>  >
>  > \def\TUG/{TeXLive User Group(TUG) \def\TUG/{TUG}}
>  >
>  > And I have a couple of dozen in the book, so I want
>  > \newabbr{TUG}{TeXLive User Group}
>  >
>  > Now comes the hard bit,  I want to reset these at the start of each chapter.
>  >
>  > \def\mychapter#1{\resetdefs
>  > \chapter{#1}
>  > }
>  >
>  > So I'm trying:
>  >
>  > \def\newabbr#1#2{%
>  > \edef\nnnn{\resetdefs}%
>  > \expandafter\def\csname#1\endcsname/{#2 (#1)
>  > \expandafter\def\csname#1\endcsname/{#1}}%
>  > \def\resetdefs{\nnnn \expandafter\def\csname#1\endcsname/{#2 (#1)}}%
>  > }
>  >
>  > But I'm getting a recursion error, input stack full.
>  >
>  > Any ideas?
>  >
>  > Cheers,
>  > Geoff Russell
>  >
>
>
>
>
> --
>  Zdeněk Wagner
>  http://hroch486.icpf.cas.cz/wagner/
>  http://icebearsoft.euweb.cz
>


-- 
6 Fifth Ave,
St Morris, S.A. 5068
Australia
Ph: 041 8805 184 / 08 8332 5069


More information about the tex-live mailing list