2

Code

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

Output

enter image description here

Wanted output: no special effect of underscores.


How can you disable the current function of underscores?

  • 4
    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
  • 1
    @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
5
 \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.

| improve this answer | |
  • 1
    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
4

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}

enter image description here


I'm lost with your point about comments, so I included a comment.

| improve this answer | |
  • Yes, one option. I will see how the changed catcodes will behave. If they fail, then I think this is a very good option. – Léo Léopold Hertz 준영 May 14 '16 at 21:25
  • 2
    They of course fail badly, once you have %s in your urls. – yo' May 14 '16 at 21:26
  • How can you solve the problem with comment signs inside urls? – Léo Léopold Hertz 준영 May 14 '16 at 21:29
  • 2
    @Masi As you see, I solved it. My url contains a %. Now I'm off, good night. – yo' May 14 '16 at 21:29
  • I think it is not necessary to have percentage signs in links because you can always expand them before having them in your document. I however created a test case about this problem (test case 8 here tex.stackexchange.com/q/309541/13173) for the future work. – Léo Léopold Hertz 준영 May 14 '16 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.