2

I am using polyglossia to write a mixed language document. The main language is Arabic, although my files are named with english script. My latex document includes a picture:

\includegraphics[height=4.4in]{images/lectureoverview1.pdf}

Notice that the filename itself is not in Arabic script.
When I switch to draft mode using \documentclass[12pt,oneside,draft]{report} polyglossia now issues an error because the file name itself images/lectureoverview1.pdf is not in Arabic script. But What's the best way round this, since I really need Draft mode?

MWE is as follows, with the key change in the first line, whether draft mode or not.

\documentclass[12pt,oneside,draft]{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.70]{Scheherazade}
\newfontfamily\englishfont[Script=Latin]{Linux Libertine O}
\begin{document}
\includegraphics[height=4.4in]{images/lectureoverview1.pdf}
\end{document}
2

The error is due to not having defined a monospaced font for Arabic, so the default one (Latin Modern Mono) is chosen; since it doesn't support the Arabic script, the message

! Package polyglossia Error: The current roman font does not contain the Arabic script!
(polyglossia)                Please define \arabicfont with \newfontfamily.

is issued. It's a well known problem with Polyglossia that such a message refers to \arabicfont and not to \arabicfonttt (the same happens for the sans serif case). See polyglossia and minted - The current roman font does not contain the Hebrew script!

The problem is solved by defining \arabicfonttt:

\documentclass[
  draft
]{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.70]{Scheherazade}
\newfontfamily\englishfont[Script=Latin]{Linux Libertine O}

\newfontfamily\arabicfonttt{Latin Modern Mono} % maybe one that supports Arabic
% or define \setmonofont to one that supports arabic
% \setmonofont{...}

\begin{document}
\includegraphics[height=4.4in]{duck}
\end{document}

Here I use again Latin Modern Mono; of course this won't do if you need Arabic in monospaced text.

  • Extra explanation helpful. – Tim Sep 13 '15 at 14:06
2

I think it should be enough to use \textenglish but \ttfamily used to set the filename seems to want to switch back, so this just locally disables it, setting the filename in Roman.

\documentclass[12pt,oneside,draft]{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.70]{Scheherazade}
\newfontfamily\englishfont[Script=Latin]{Linux Libertine O}
\begin{document}

\textenglish{%
\def\ttfamily\relax
\includegraphics[height=4.4in]{example-image}}

\end{document}
  • This is more complicated than the answer below, and requires more changes – Tim Sep 13 '15 at 14:07
2

You can define yourself a key to switch the ttfont (I have no idea why graphicx expects \\ at the end):

\documentclass[12pt,oneside,draft]{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.70]{Scheherazade}
\newfontfamily\englishfont[Script=Latin]{Linux Libertine O}
\makeatletter
\define@key{Gin}{ttenglish}[]{\let\ttfamily\ttfamilylatin\\}
\makeatother
\begin{document}


\includegraphics[height=4.4in,ttenglish]{example-image}
\end{document}

You could also set \ttfamily to some font which has the script:

\documentclass[12pt,oneside,draft]{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.70]{Scheherazade}
\newfontfamily\englishfont[Script=Latin]{Linux Libertine O}

\newfontfamily\ttfamily[Script=Arabic, Scale=1.70]{DejaVu Sans Mono}% 
\begin{document}


\includegraphics[height=4.4in]{example-image}

\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.