[texhax] Passing Underscore

pierre.mackay pierre.mackay at comcast.net
Tue Sep 19 21:58:43 CEST 2006

Peter Abbott wrote:

>I have file names containing the _ (underscore) character and need to 
>pass the _ into a macro as part of a file name. \_ inserts protect command etc.
>Can I declare it as a 'normal' character?
>Peter Abbott
>TeX FAQ: http://www.tex.ac.uk/faq
>Mailing list archives: http://tug.org/pipermail/texhax/
>More links: http://tug.org/begin.html
>Automated subscription management: http://tug.org/mailman/listinfo/texhax
>Human mailing list managers: postmaster at tug.org
You can always change the catcode of any character that goes into input. 
You have to think about what that implies, and you are wise to have a 
readymade way of reverting to the default catcode.

The commonest use of this capability is in the two macros
\makeatletter and \makeatother, which are used to frame an environment 
in which @ is a normal letter of catcode 11. That is the commonest way 
of hiding macro names from promiscuous use or alteration.

\catcode `\_ = 11 % will do the trick. I would be inclined to use it in 
a well-defined and delimited module. Look at page 44 of the TeXbook, for 
the `\ part of the syntax.

Pierre MacKay

More information about the texhax mailing list