[texhax] combing adjacent macros

Henry Kannapell hnk at cs.stanford.edu
Mon May 25 00:18:21 CEST 2009


I am a novice Tex user, but would like to find a method of combining  
adjacent macros that I define in a style sheet.

The macros are for a crossword typesetting, based on Gerd Nuegebauer's  
excellent cwpuzzle.dtx

I have defined macros for tags at the end of the clues, so I can keep  
the formatting consistent. They are very simple, such as

\newcommand\hyph{\emph{(hyph.)} %% hyphenated
\newcommand\var{\emph{(var.)} %% variation
\newcommand\slang{\emph{(slang)} %% slang term

etc.

In some cases, however, I have more than one tag. What I would like to  
do is then have a pair of adjacent macros expand like this:

\hyph\var -> (hyph., var)

I think I could create a recursive macro which checks the second  
command, and if it is in the same group of macros (there are perhaps 9  
that I have defined), combine them. But that would be 9 different  
definitions, with 9 different checks in each one - surely there is a  
better solution than that.

A general solution would be able to deal with an unlimited number of  
adjacent macros. And, it should be able to define a group composed of  
the 9 macros, and do the recursion based on the group, not each  
individual macro.

I fear I don't understand enough about Tex to approach the problem. I  
would appreciate any help or directions.

Henry Kannapell






More information about the texhax mailing list