1

Refer to this question and answer. When I compile the file below (encoded in utf-8) with pdflatex, only the middle option produces a working link as opposed to all three in the linked question. In addition, the third option doesn't display correctly. Is this a bug in hyperref? I can typeset the ø fine outside the \url command.

I would prefer to use the third option to typeset a link, as it handles linebreaking for me. Is there a workaround or am I doing something wrong? Is there a way to make \href handle linebreaking like \url does?

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\begin{document}
\href{https://da.wikisource.org/wiki/Forsøg_over_den_electriske_Vexelkamps_Indvirkning_paa_Magnetnaalen}{https://da.wikisource.org/wiki/Forsøg\_over\_den\_electriske\_Vexelkamps\_Indvirkning\_paa\_Magnetnaalen}

\href{https://da.wikisource.org/wiki/Fors\%C3\%B8g_over_den_electriske_Vexelkamps_Indvirkning_paa_Magnetnaalen}{https://da.wikisource.org/wiki/Forsøg\_over\_den\_electriske\_Vexelkamps\_Indvirkning\_paa\_Magnetnaalen}

\urlstyle{same}
\url{https://da.wikisource.org/wiki/Forsøg_over_den_electriske_Vexelkamps_Indvirkning_paa_Magnetnaalen}

\end{document}

Screenshot of my pdf viewer (Adobe Reader): Screenshot in Adobe Reader

  • Which TeX distribution do you use, and how recently did you update it? If I run your code on a MacTeX2015 (on a MacBook Pro running MacOSX 10.10.5), all three URL strings in the pdf file provide valid links to the wikipedia page. – Mico Sep 3 '15 at 18:47
  • The PDF format expects 7-bit ASCII for the URI. Therefore, the second, percent escaped version is correct. – Heiko Oberdiek Sep 3 '15 at 18:51
  • My TeX distribution is TeX Live. My pdflatex version is pdflatex --version pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014/W32TeX) kpathsea version 6.2.0. I'll update all my packages with TeX Live Manager and try again. – Pétur Sep 3 '15 at 18:53
  • I updated and now my version is 3.14159265-2.6-1.40.16. The output is exactly as before. @HeikoOberdiek is there a way to use the percent escaped version of the url in the \urlcommand while displaying the character ø? Or to make hyperref break between lines like \url? – Pétur Sep 3 '15 at 19:19
  • 2
    @Pétur No, but there is \href, e.g. \href{<URL, percent encoded>}{\nolinkurl{<URL>}}. – Heiko Oberdiek Sep 3 '15 at 19:42

Your Answer

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

Browse other questions tagged or ask your own question.