Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\documentclass{article} % compile with xelatex
\usepackage{hyperref}
\usepackage{polyglossia} 
  \setmainlanguage{hebrew} 
  \setotherlanguage{english}
  \newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}% or{SBL Hebrew}
\begin{document}
  \begin{english}English separates Yankees and Brits?
  \url{http://www.google.com}
  \end{english}
\end{document}

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?

share|improve this question
    
Thanks @Martin for adding the URL tag! –  Yossi Gil Feb 22 '11 at 14:32
add comment

3 Answers 3

up vote 8 down vote accepted

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:

\renewcommand\UrlFont{\ttfamilylatin}
share|improve this answer
    
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
add comment

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.

share|improve this answer
    
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
add comment

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.

\def\UrlFont{\usefont{EU1}{lmtt}{m}{n}}
share|improve this answer
    
Wow! This did it. –  Yossi Gil Feb 22 '11 at 15:21
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.