Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

verbatim-style underscore in math mode

797 views
Skip to first unread message

Jan Van den Bussche

unread,
Jul 1, 1993, 11:20:20 AM7/1/93
to
I'm using LaTeX.

When not in math mode, \verb|_| and \_ both give underscores, but of a
different style. Let's call the style of the first the "verbatim" one and the
style of the second the "ordinary" one.

When in math mode, both \verb|_| and \_ give the ordinary underscore! How can I
get the verbatim underscore in math mode?

My first guess was $\mbox{\verb|_|}$ but that gives an error message.

Best wishes, --Jan (vdb...@wins.uia.ac.be)

Éamonn McManus

unread,
Jul 2, 1993, 9:12:43 AM7/2/93
to
vdb...@wins.uia.ac.be (Jan Van den Bussche) writes:
> When in math mode, both \verb|_| and \_ give the ordinary underscore! How can I
> get the verbatim underscore in math mode?
> My first guess was $\mbox{\verb|_|}$ but that gives an error message.

Thinking on the same lines, $\hbox{\verb|_|}$ will work. The problem
with just \verb|_| is that \mathcode`_ = "8000, so when TeX comes to
typeset a _ in math mode, it uses its \active meaning. You could
always change the \mathcode to get around this problem. The reason
\mbox doesn't work is that it reads its argument before the inner
\verb gets a chance to change \catcodes. latex.tex defines:
\def\mbox#1{\leavevmode\hbox{#1}}
This might just as well be:
\def\mbox{\leavevmode\hbox}
which would be marginally more efficient and would avoid \catcode
problems like the above. (Well, the original definition allows you to
say, e.g., "\mbox X" instead of "\mbox{X}", but I don't know if
anybody uses this capability.)

,
Eamonn
"The future belongs to those who can smell it coming." -- RuPaul

David Carlisle

unread,
Jul 2, 1993, 2:01:51 PM7/2/93
to

>>>>> On 1 Jul 93 15:20:20 GMT, vdb...@wins.uia.ac.be (Jan Van den Bussche) said:

Jan> I'm using LaTeX.

Jan> When not in math mode, \verb|_| and \_ both give underscores, but of a
Jan> different style. Let's call the style of the first the "verbatim" one and the
Jan> style of the second the "ordinary" one.

Jan> When in math mode, both \verb|_| and \_ give the ordinary underscore! How can I
Jan> get the verbatim underscore in math mode?

If you pick up Rainer Sch\"opf's verbatim.sty, Your first try would work:

$\verb|_|$ looks like \verb|_|

verbatim.sty is available from most places, at stuttgart it is

soft/tex/macros/latex/distribs/verbatim/*

Jan> My first guess was $\mbox{\verb|_|}$ but that gives an error message.

You can not use \verb inside the argument to a command.

If you dont want to use verbatim style you need to figure out how to
get the `_' character from the \tt font into a math formula.

Without going into details of font choices NFSS or not etc, one way
that will work is to go:

$\mbox{\tt\string_}$


David

0 new messages