# Why is hyperref inverting URL /'s to a backslash

This code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\begin{document}
\begin{center}
\url{http://demonstrations.wolfram.com/preview.html?draft/93173/000001/BallisticHookePendulum}
\end{center}
\end{document}


prints the URL properly. But if you click on it in the PDF the URL it tries to open have some of the /s changed by \s. Any idea why this is happening?

• Welcome to TeX.SX! I can't reproduce this behavior (the URL is referenced to correctly). I guess it's a PDF viewer quirk: what OS and viewer are you running? – egreg Dec 21 '13 at 17:51
• Oh. It also happens with \href{demonstrations.wolfram.com/preview.html?draft/93173/000001/…}{link} I'm using TexMaker to edit, and MikTex in Windows. I've had no problem with any other url I have tried before... – Andrestand Dec 21 '13 at 17:58
• Let's hope somebody with MiKTeX can help. – egreg Dec 21 '13 at 18:01
• Works fine for me on miktex 2.9. Is your system up-to-date? – Ulrike Fischer Dec 21 '13 at 18:19

I don't have the exact answer, but rather an observation. I would have posted this as a comment but I cannot because of my low reputation. I am also using TexMaker, and I wanted to put this link into my report:

http://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/http.html%27)


It didn't work, as one / was treated as a \. The forward slashes that are converted to back slashes are the ones following a ? in the url. In the url you provide, after preview.html there is a question mark so the rest becomes draft\93173\000001\BallisticHooke‌​Pendulum. For my link, there's a question mark after doc_for, and the rest of the url is interpreted as object=section(%27packages\http.html%27).

As far as I've seen this is not a (pdf)Latex/MikTex problem. I have tried opening the same url with Adobe Reader and it works fine. It seems that only TexMaker gets it wrong on my computer. I am not sure why, however.

• Have you checked the PDF file as suggested in my answer? It should contain /URI(http://www.swi-prolog.org/pldoc/doc_for?object=section$$%27packages/http.html%27$$) (the backslashes here are just escaping the parentheses characters inside a parentheses delimited string). Especially there is a forward slash before http.html. If the URL is correct, then I suggest that you can make a bug-report for TeXMaker. – Heiko Oberdiek May 2 '14 at 20:48
• Yes I have checked it, and it does indeed have a forward slash instead of a back slash exactly like you have in your comment. I guess that makes it a TexMaker bug! – George Flourentzos May 2 '14 at 20:55
• I have filed a bug report which can be found here: code.google.com/p/texmaker/issues/detail?id=1284 – George Flourentzos May 2 '14 at 21:09

Package hyperref does not change / to \ inside URLs. The example correctly works with drivers pdftex, dvips, hypertex, xetex.

Therefore it would be nice to have more information pieces:

• Which program is used to convert the TeX file to PDF?
• Which hyperref driver is used (see console output or .log file)?
• At which places / is converted?
• Which PDF viewer is used to view the PDF file?
• Which browser is called by the PDF viewer to show the URL?

If the PDF file is generated without object compression, then the URL can be inspected by viewing the PDF file as text file, search for '/URI'. Object compression is a feature of PDF 1.5. For example, it can be turned off by \pdfobjcompresslevel=0\relax, if pdfTeX is used in PDF mode.

• I really don't know why, but the problem no longer arises. As my knowledge about LaTeX is very short, I only can say I was using TeXMaker tools, its 'fast compile' command, to get the PDF. I was using the TexMaker viewer and also PDF XChange Viewer, where when I clicked it sometimes tried to open "C:/....../http://...." or something similar. TexMaker viewer tryed to open the URL with the last 3 slashes changed: demonstrations.wolfram.com/preview.html?draft\93173\000001\BallisticHookePendulum My default browser is Chrome. – Andrestand Dec 22 '13 at 9:42