I have an URL containing Cyrillic characters, e.g.: \href{https://bg.wikipedia.org/wiki/Начална_страница}{Bulgarian Wikipedia Main Page}

When I compile the document, the link points to a local file such as: file:\\\Users\me\path\to\source\file\location\followed_by_something_mangled which is obviously not the desired result.

It appears that \href cannot properly identify the link type ("url link") and detects a "file link".

One way to circumvent this is described here (in short: one encodes the original Cyrillic-containing URL to https://bg.wikipedia.org/wiki/%D0%9D%D0%B0%D1%87%D0%B0%D0%BB%D0%BD%D0%B0_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0)

This, however, aside from being ugly, contains all those % signs, which are interpreted as comments when \href is used inside, say, \textit{} and the compilation fails because of parenthesis mismatch.

Any ideas how to fix that?

P.S. I use XeLaTeX and my preamble is:


\setmainfont{Free Serif}


A similar problem appears when I use pdfLaTeX + inputenc

  • You can use short urls. – Ruben Kazumov Nov 25 '15 at 15:10
  • Good point! A disadvantage of this is that the reader won't be able to see the destination URL. – the.real.gruycho Nov 25 '15 at 16:02
  • 1
    @RubenKazumov P.S. +There should be some way to handle this within TeX. If it does not exist at the moment, it should be developed (and probably will, soon enough). I see no reason why using Cyrillic (or other non-Latin alphabets) in URLs should be such a hassle. – the.real.gruycho Nov 25 '15 at 16:14
  • It is true. But anyway, you do not expect, the readers will rewrite whole url by themselves. You can keep native url and add readable descriptive part in xelatex – Ruben Kazumov Nov 25 '15 at 16:34
  • @RubenKazumov Yes, of course I don't expect anyone to rewrite the URL. I mean that the URL appears if one hovers over the link text (in the example above, it's "Bulgarian Wikipedia main page"). If the reader sees the short URL, they don't immediately know where it will take them. – the.real.gruycho Nov 25 '15 at 16:50

The address with percent encoding is correct for the first argument of \href. If \href is used inside the argument of another command, then the percent % can be escaped with the backslash \% to prevent the percent character being interpreted as comment character:

    Bulgarian Wikipedia Main Page}%

Another variation:


  \catcode`\^^A = 14 % ^^A is comment char

    Bulgarian Wikipedia Main Page}%
  • Yes, I had thought of that (I should probably have mentioned it in the question), but this seems somewhat impractical (especially for longish URLs). Another workaround (similar in spirit) is to use \textit inside \href's second argument \href{url}{\textit{text}}, Of course one can use some external script to escape all the % signs, but it's still a multi-step solution (1-get encoded URL; 2-escape the % signs with script). Is there really no way to handle Cyrillic internally? Non-latin URLs are now quite common, and will be getting more so in the future. – the.real.gruycho Nov 30 '15 at 18:30
  • @Tropcho I have added an example, which avoids the additional escaping of the percent characters. – Heiko Oberdiek Nov 30 '15 at 18:44
  • Many thanks! That does seem more tractable indeed. Hopefully we'll see a hyperref patch that takes care of all that soon :) – the.real.gruycho Nov 30 '15 at 20:16

After playing with it an hour or so I have found this workaround. I give \href the tinyUrl and have it print out the website in Cyrillic. Here's the code:

\footnote{Wikipedia: Биоелектричен потенцијал 

Here I use a tinyUrl to avoid the hassle with escaping %, and \mkurl is just a command that stylizes the text to look like a \url link. I didn't find which font is default, but my bet is CMU Typewriter Text which looks very close, except that the \url typeset is slightly bolded (\textbf bolds it too much). Here's my setup for the colors:

\definecolor{bbe}{rgb}{0, 0.27, 0.52}
\newfontfamily\urlfont[]{CMU Typewriter Text}
\newcommand{\mkurl}[1]{\urlfont{\color{bbe} #1}}

Looks good enough for me :)

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.