[texhax] making underscore a letter

Adam ENDRODI borso at vekoll.saturnus.vein.hu
Thu Apr 19 13:01:00 CEST 2007


Hello again,


Do you know about a compelling reason why '_' is left to be the
subscription character in normal mode in LaTeX?

I'm writing a package of authoring macros, some of them are like

\def\Code#1{\hypertarget{#1}{\texttt{#1}}}

so later #1 can be \hyperlink-ed.  Now, \Code{some_funny_function()}
is obviously a problem: left as it is makes latex complaint, escaping
the underscores makes hyperref think weird things.

To cut the problem short I've decided to make '_' a letter, so latex
would accept it in normal mode:

\catcode`_=11
\everymath\expandafter{\the\everymath\catcode`_=8}
\everydisplay\expandafter{\the\everydisplay\catcode`_=8}

What I'd like to know is, do you agree with this approach?
What trouble should I prepare for?  I'm using pdflatex,
hyperref, and {listings}.

Thanks,
adam


More information about the texhax mailing list