Subject: Re: bug#23102: Wrong usage of underscore in .tex files

From: Tassilo Horn <[email-masked]>
Date: Mon, 28 Mar 2016 11:46:18 +0200

Angelo Graziosi <[email-masked]> writes:

Hi Angelo and John,

>>> Attached is how Emacs displays the usage of underscore out of
>>> mathematics and friends, for example:
>>
>>> \href{http://www.foo.it/bla_bla.html}{BLA_BLA}
>>
>> I'm pretty sure that the underscore in BLA_BLA here is incorrect LaTeX.
>> Shouldn't it be BLA\_BLA, which does display correct in latex-mode?

Well, the plain underscore in BLA_BLA is indeed wrong but the plain
underscore in the URL *is* correct though escaping it with \ is also
permitted.

> Yes, it works but it is only a workaround in my opinion: treating an
> url string as in mathematics seems wrong to me.
>
> I found no example suggesting to use \_ in \href{}{} or \url{} commands.

Right, you don't need to use \_ in \url{} or \href's 1st argument.
Interestingly, stock `latex-mode' displays the argument of \url{} as
verbatim without subscripting the character after the _.  It should do
the same with the first argument of \href.

> I tried with Atom Editor and its language-latex package, and the above example
> (BLA_BLA...) is displayed as expected from me. See attachment.

GNU AUCTeX does the same: _ has only subscript semantics in math mode.

Bye,
Tassilo