[texhax] Macros that define other macros

Uwe Lück uwe.lueck at web.de
Mon Dec 3 09:39:01 CET 2012


Am Sonntag, den 02.12.2012, 21:04 -0300 schrieb Pablo Mayckon:
> I would like to define macros that in their turns define other macros, in the
> spirit of the following erroneous TeX code:
> 
> ---------------------
> \def\macromaker#1{%
>   \def\submacro#1{I am submacro #1}%
>   \def\anothersubmacro#1{I am another submacro #1}}

Inside the replacement text of \macromaker, you must double 
`#'s for "submacros": \def\submacro##1{I am submacro##1}. 
See Chapter 20 of The TeXbook.

Another mistake seems to be that your \macromaker just 
gobbles its own parameter, I believe that it does not 
make sense for \macromaker to have a parameter.

Other \macromaker's may well have parameters, to collect 
what is going to be defined and how, perhaps conditionally 
only, LaTeX's \newcommand is of this kind.

Cheers,

    Uwe.




More information about the texhax mailing list