10

I am trying to write an URL using breakurl, that includes an accented character. I am trying to use pdflatex with utf8 inputenc (also tried utf8x). But I can't get a decent result.

My best result is presented by this minimal working example:

\documentclass{article}

\usepackage[utf8x]{inputenc}
\usepackage{hyperref}
\usepackage{url}

\begin{document}
\url{\detokenize{http://coração.net}}

\end{document}

The link is created correctly, but the text shown in the PDF is not the correct one (misses the non ascii characters).

Suggestions are welcome.

  • \detokenize will completely break pdflatex's handling of utf-8. – David Carlisle Dec 18 '17 at 16:20
  • Sure, but removing it doesn't help too. – Alberto Dec 18 '17 at 16:26
  • Why do you need that? I don't think url with non-ascii characters are supported anywhere (feel free to correct me about this). Also there is no need to load url if you load hyperref. – Skillmon Dec 18 '17 at 16:33
  • 7
    \href{\detokenize{http://coração.net}}{\texttt{http://coração.net}} – user91669 Dec 18 '17 at 16:36
  • 3
    @Skillmon unfortunately unicode domains are out there, and they are a big danger for phishing, as there are ways to make similar looking urls pointing to different places. Look here: wordfence.com/blog/2017/04/chrome-firefox-unicode-phishing – Alberto Dec 18 '17 at 16:41
0

The following code works with xelatex:

\documentclass{article}
\usepackage{fontspec,hyperref}
\begin{document}
\url{http://coração.net}
\end{document}
  • 2
    Yep, unfortunately I needed to use pdflatex. – Alberto Dec 18 '17 at 17:23
0

There are at least two issues here. First, you need to switch to the 8-bit T1 encoding, or PDFTeX will by default use an even older 7-bit encoding for output. Second, hyperref declares its own \url command and does not seem to be compatible with \usepackage{url}.

The following workaround appeared to work for me:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc} % The default since 2018.
\usepackage[unicode]{hyperref}

\begin{document}
\href{http://cora\%E7\%E3o.net}{\texttt{http://coração.net}}
\end{document}

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.