🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #9609

Disabling the underscore character

#9609
From: MT Raghunath
Date: Wed, 30 Dec 1992 21:40
27 lines
1174 bytes
I am trying to write a tex macro that needs to print a
file name as part of what it does.  The macro does not
work if the file name has an underscore character in it,
since it interprets the underscore as the subscript
character and starts inserting $ signs.

The crux of what I am trying to do is:

\def\foo#1{ {\tt #1} }

\foo{file_name.ext}

I tried defining foo as follows:

\def\foo#1{ {\catcode`_=12 {\tt #1} } }

but that does not work either.  I tried many different
variations without any success.  It appears that I have
to do the catcode stuff when I invoke foo:

{\catcode`_=12 \foo{file_name.ext} }

Is there a way of avoiding this and doing everything
inside the macro?

Thanks,
mtr
Technical Details
Message-ID: <1ht4viINNnaj@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!agate!gazpacho.Berkeley.EDU!mtr

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!ames!agate!gazpacho.Berkeley.EDU!mtr
From: mtr@gazpacho.Berkeley.EDU (MT Raghunath)
Newsgroups: comp.text.tex
Subject: Disabling the underscore character
Date: 30 Dec 1992 21:40:02 GMT
Organization: University of California, Berkeley
Lines: 27
Distribution: world
Message-ID: <1ht4viINNnaj@agate.berkeley.edu>
NNTP-Posting-Host: gazpacho.berkeley.edu