[texhax] making underscore a letter

Philip Taylor (Webmaster) P.Taylor at Rhul.Ac.Uk
Thu Apr 19 15:15:11 CEST 2007


Morten Høgholm wrote:

 > The usual trouble of trying to change catcodes on the fly: Once an
 > argument is read, catcodes are locked and can't change, unless you go
 > via \scantokens or a temporary file (which is what \scantokens is only
 > much faster).

There is an alternative approach : use a tail-recursive
macro with a delimited parameter structure

	(say \foo #1_#2\sentinel)

The first delimiter is "_" with its new catcode, and
the macro expands to yield

	#1_#2

with the original catcode of "_".  Tail recursion
is needed to cope with further "_"s in #2.

Suggested to DEK at TUG's tenth anniversary meeting.

Philip Taylor


More information about the texhax mailing list