12

Trying to use minted with Hebrew as the default language with polyglossia:

\documentclass{article}
\usepackage{minted}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=hebrew, numerals=arabic]{hebrew}
\setotherlanguage{english}
\newfontfamily\hebrewfont{David CLM}

\begin{document}
בדיקה

\begin{english}
\begin{minted}{bash}
    $ for i in {1..2}; do echo 'Hello World'; done
    Hello World
    Hello World
\end{minted}
\end{english}
\end{document}

Results in:

$ xelatex -shell-escape test
! 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.1 \begin{Verbatim}[commandchars=\\\{\}, ]

I think I understand what the error is saying, but not sure why.

I'm in the english environment which should use the default English font... So why am I getting errors about Hebrew stuff?

(I did manage to workaround it by setting the default language to English, but that made other things break unfortunately)

10

It's a clear bug in how Polyglossia manages the situation, as it seems not taking into account the current language. A temporary workaround is to say

\let\hebrewfonttt\ttfamily

just after \newfontfamily\hebrewfont{David CLM} (it suffices to say it in the preamble, anyway). This assuming that you don't need Hebrew in the minted environment.

  • 1
    Thanks everybody I had similar problem for arabic font and replaced '\let\hebrewfonttt\ttfamily' by '\let\arabicfonttt\ttfamily' and all works well for verbatim the english characters. but when I write arabic characters between \begin{verbatim} and \end{verbatim}, it doesn't recognize it and compiles nothing or blank line. How can I write arabic characters in verbatim ? – Faouzi Bellalouna Oct 17 '14 at 7:55
  • @FaouziBellalouna You need a (monospaced) font that supports Arabic. Sorry, but I can't say more without a real example. Will you make it in a new question? – egreg Oct 17 '14 at 8:03
  • I just saw your comment. I'll make a new question soon. Thanks – Faouzi Bellalouna Oct 17 '14 at 12:11
  • @ egreg. Here's the question I made. tex.stackexchange.com/questions/207636/verbatim-and-polyglossia – Faouzi Bellalouna Oct 17 '14 at 12:47

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.