# How to Disable Function of Underscores?

Code

\documentclass{article}
\begin{document}
http://apps.who.int/iris/bitstream/10665/75146/1/9789241548441_eng.pdf#page=35
\end{document}


Output

Wanted output: no special effect of underscores.

How can you disable the current function of underscores?

• Although there's a way to do it, it's not recommended. Can't you just load the url package, and wrap URLs in \url{...}? That will work. – Alan Munn May 14 '16 at 18:10
• @AlanMunn I suspect this is connected to .tex Notes for Overview with Inline Comments for Non-LaTeX Users? – Torbjørn T. May 14 '16 at 18:11
• @AlanMunn I really would like to disable it. I cannot use it \url{...} in all environments. So I really need it. Tor's pointed out thread is one example where I will have problems with % http://.... – Léo Léopold Hertz 준영 May 14 '16 at 18:12
• Load the underscore package then. That should probably do the trick. You need to make sure you're using a font encoding (minimally T1 if using pdflatex) that supports the _ character. But you'll also have to escape things like # too. – Alan Munn May 14 '16 at 18:14
• @Masi Ever heard of \urldef from the package url? It can be used in all environments. Problem solved. Simply do what you're supposed to do and do not re-invent America. – yo' May 14 '16 at 21:08

 \catcode\_=12


will make _ a normal punctuation character.

You will need

\usepackage[T1]{fontenc}


as OT1 encoded fonts don't have a _ in the ASCII slot.

• How can you disable hastag (#)? I tried unsuccessfully \catcode #_=11. How did you know which number you can use for the mapping? – Léo Léopold Hertz 준영 May 14 '16 at 19:36
• @Masi you don't want a _ in the # version:-) just replace _ by # in the above any tex tutorial will tell you the catcodes 11 is letter 12 is punctuation 13 is active – David Carlisle May 14 '16 at 20:38
• @Masi 12, presumably, like _ – David Carlisle May 14 '16 at 20:40
• @Masi you did something wrong then – David Carlisle May 14 '16 at 20:44
• @Masi it works as described. You must have made an error somewhere – David Carlisle May 14 '16 at 21:00

Well, I can do this with url's \urldef:

\documentclass{article}

\usepackage{url}

\urldef \myCuteLittleURL \url|http://whatever/under_score#hash%percent|

\begin{document}

Here I use the URL and have a comment at the very same place:
\myCuteLittleURL % http://whatever/under_score#hash%percent

\end{document}


• They of course fail badly, once you have %s in your urls. – yo' May 14 '16 at 21:26
• @Masi As you see, I solved it. My url contains a %. Now I'm off, good night. – yo' May 14 '16 at 21:29