In a mixed language document, I try to use a URL. Here is minimal input demonstrating

\documentclass{article} % compile with xelatex
  \newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}% or{SBL Hebrew}
  \begin{english}English separates Yankees and Brits?

Now, polyglosssia does not like this at all, complaining that:

! Package polyglossia Error: 
The current roman font does not contain the Hebrew script!
Please define \hebrewfont with \newfontfamily.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.

l.9 \url{http://www.google.com}

I am confused. Didn't I switch to English on line 8?


If you change your link to \href{http://www.google.com}{Google} instead of using \url it works fine.

However, this doesn't actually solve the problem directly. Building on Leo's answer, but using polyglossia methods, (and LaTeX syntax) the correct solution is the following:

  • But we cannot use \url{http://foo.bar/%12%34%56#7890} then. – Leo Liu Feb 22 '11 at 15:15
  • @Leo I've updated my answer based on yours. – Alan Munn Feb 22 '11 at 15:32
  • Does anyone know how to solve this problem with \verb+XXX+, which produces the same error message? Perhaps it is the case as @Ulrike suggested, namely a bug with polyglossia font changing algorithm? – Yossi Gil Feb 22 '11 at 15:40
  • 2
    @Yossi: It is a problem of polyglossia. You can redefine \ttfamily or internal macro \verbatim@font to fix the bug. – Leo Liu Feb 23 '11 at 4:37

It has nothing to do with hyperref. \url uses \ttfamily as font. You get the same message if you simply call \ttfamily. At my opinion this is a bug in the font switching system of polyglossia. The script=hebrew option is still present after a language switch.

  • Not so sure. I got the same problem with using just old plain \verb+google.com+ – Yossi Gil Feb 22 '11 at 15:22
  • 2
    +1. I agree that it is a problem of polyglossia. english envrionment does not affect \ttfamily here. For verbatim text, you can redefine \ttfamily to \fontfamily{lmtt}\selectfont or something similar after document environment, if typewriter typeface is not required in Hebrew text. This would also solve the problem of \url. – Leo Liu Feb 22 '11 at 15:37
  • The typewriter typeface is used primarily to demonstrate computer input. Not so common to write instructional material in languages other than English, but it does occur. – Yossi Gil Feb 22 '11 at 15:59
  • 2
    @Yossi. Naturally you get the same problem with \verb: it use the typewriter font too. You get the error also if you use \sffamily. One could perhaps get around it by setting some fonts explicitly. But whatever polyglossia is doing here, it is at my opinion not sane and should be revised. – Ulrike Fischer Feb 22 '11 at 19:30

It's not a bug of url package. \url use \ttfamily by default, however, the default typewriter font lmtt is not for the default language Hebrew. Just redefine \UrlFont to fix it.

  • 1
    @Yossi I changed my answer to reflect this, but using polyglossia methods. It provides a \ttfamilylatin command for this purpose. – Alan Munn Feb 22 '11 at 15:32

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.