\catcode`\_=12
… in the preamble. Thereby the underscore looses its subscript function (category code 8) and is treated like any other puctuation character (category code 12).
As a linguist I do not need the underscore as a shortcut for subscript in math mode. If I want, I can still do it by “\sb” instead of the “_”. (\sb is actually short enough.)
I then can define my \ru just like this:
\providecommand{\ru}[1]{#1}
(I may want to fill it with additional commands later.)
I get the feeling that changing the category code of certain special characters may be the most accessible (if not the only) way of accepting verbatim text as an argument of a command.
This whole thing around my \ru command motivates me to go through some introduction to TeX. Very nice explanation of catcodes and their purpose I found in Eijkhout’s TeX by Topic on p. 29.
D. E. Knuth certainly was a smart guy.
5 comments:
You shouldn't say "Knuth was a smart guy". He is a smart guy — an old man but still around. You really scared me!
Thanks for a great blog, BTW!
/BP — phiilologist and household chore hacker.
Found the solution to your problem. If you still care. :)
See "LaTeX and those pesky underscores!"
It basically boils down to
\begingroup \catcode_=\active
\gdef\foo{\begingroup\catcode_=\active\foox}
\gdef\foox{... do real work ...\endgroup}
\endgroup
I think I should say that your site in many respects opened my eyes on this matter.
Today I made a great discovery for himself / bagodarya only your site and this article
Appreciatte your blog post
Post a Comment