5

I'm trying to include Arabic text in an English document (I'm a new latex user), but I can't seem to get any Arabic text to render at all, using xelatex or any kind of tex. I'm using texshop 3.51 on a mac. I can't get this basic example to work, it just displays question marks in the output pdf.

\documentclass[12pt]{article}
\usepackage[utf]{arabxetex}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\begin{document}
\begin{arab}[voc]
وَهَذِهِ فِقرَةٌ بِالعَرَبِيَة مَعَ كَلِمَة اِنكلِيزِيَة
\end{arab}
\end{document}

I've downloaded Amiri (and also Scheherazade and Lateef) into Fontbook, and they show up if I go Source->Font->Show Fonts in texshop. If I remove the Amiri part it still doesn't work.

Is there anything I can do? I've looked at other links here, like Arabic text with Polyglossia and How write a one-sentence arabic text in a latin document? but I can't even render any of those examples.

Thank you so much for any help! I'll love you forever if I can get this to work.

  • 1
    This picture shows what I get from your very same code. – egreg Apr 16 '15 at 22:33
  • Could I ask you what OS/tex setup you're using? – peter Apr 16 '15 at 22:38
  • Welcome to TeX SE, by the way! – cfr Apr 16 '15 at 23:01
  • @peter Mac OS X 10.9, MacTeX 2014 – egreg Apr 16 '15 at 23:03
  • Also works on Arch Linux. – cfr Apr 16 '15 at 23:07
2

This is an issue with TeXShop's file encoding, not XeLaTeX itself.

In Sublime Text, this works fine for me:

% !TEX TS-program = xelatex
\documentclass[12pt]{article}

\usepackage{fontspec}
\newfontfamily\arabicfont{Al Nile}

\begin{document}
    \arabicfont وَهَذِهِ فِقرَةٌ بِالعَرَبِيَة مَعَ كَلِمَة اِنكلِيزِيَة
\end{document}

enter image description here

(sorry, I don't have a good Arabic font, I just used a mac default)

TeXShop's settings allow for the encoding to be changed, but I can't seem to make it work. (see here I've selected "Arabic, Hebrew, Persian" and changed the encoding to Unicode UTF-8, which should work in theory, but TeXshop reopens the file with question marks, and therefore passes question marks to XeLaTeX.

enter image description here

I'll keep looking at this, but for the moment as a workaround, you can use a different text editor and then compile inside terminal using xelatex [filename].


Got it!

The key was to apply the settings as I did in the above screenshot, restart TeXShop, and then reopen the file explicitly with the right encoding, then paste the Arabic in.

When you open the file, make sure the encoding is set here as well:

enter image description here

And then, it works!

enter image description here

For a new file, make sure to set the encoding here:

enter image description here

Note: These examples are all using my simplified MWE above, not @cfr's suggestion.

  • 1
    Your arabic sentence is in reverse order you need bidi package and the command \setRTL command to write right to left text like arabic – Salim Bou Sep 2 '16 at 20:24

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.