4

I'm trying to use arabic script but it seems I run into trouble, the output is just a mess of question marks, literally. I took this code from this page

(I'm on Macbook Pro Yosemite, TeXLive, TeXshop, XeLaTeX etc)

\documentclass{book}

\usepackage{setspace}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguage{arabic}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Scheherazade}

\begin{document}

Some latin text and inline arabic: \textarabic{السلام عليكم}

And for larger blocks of text you can use Arabic environment:

\begin{Arabic}

العربية أكثر لغات المجمأعلى الصفحة إلى أسفلها.

\end{Arabic}

To get even spacing between lines, you can use \verb|\lineskiplimit| command (locally or globally, preferably locally) and set spacing with \verb|setspace| or \verb|leading| package to avoid possible overlapping:

\begin{Arabic}
\lineskiplimit=-1000pt
\setstretch{1.2}

العربية أكثر لغات المجموعة السامية متحدثينَ، وإحدى أكثر اللغات انتشارًا في العافارسية والعبرية وعلى عكس الكثير من اللغات العالمية - ومن أعلى الصفحة إلى أسفلها.

\end{Arabic}

\end{document}

The output is

enter image description here

To the best of my knowledge, I have installed the Scherzade font (I see it in other softwares/Pages) but I'm not so sure about the Polyglossia thing. Anyone know how I can fix this?

  • didn't you get an error message that Scheherazade could not be found (or any other warnings in the log) ? – David Carlisle Apr 20 '15 at 14:03
  • 1
    Your example produces this output which I hope is correct (I can't read the Arabic, sorry) – David Carlisle Apr 20 '15 at 14:06
  • No, nothing I immediately can see, it prints out fine. But one thing (that I will also put in the question) is that after restarting TeXshop even the (nonlatin) text that I entered in the main .tex document is turned into a bunch of question marks. Don't know why. – Physics_maths Apr 20 '15 at 14:08
  • Yes it should produce that, but apparently not on my computer. – Physics_maths Apr 20 '15 at 14:09
  • 2
    You need to give us some hints preferably the full log file that you get added to your question in a code block. Also make sure that your file is saved as UTF-8. – David Carlisle Apr 20 '15 at 14:10
  • I just hit "Typeset" and out comes a PDF. How can I save something as UTF-8? – Physics_maths Apr 20 '15 at 14:16
  • Someone who has used texshop would be able to tell you that, every editor must have some way of specifying the file encoding, but meanwhile you could add the log to your question. – David Carlisle Apr 20 '15 at 14:18
  • You fixed my problem my friend...it was that damn UTF-8 encoding all along. – Physics_maths Apr 20 '15 at 14:24
  • 1
    @Love Learning To use the UTF-8 Unicode encoding on a per-file basis, you can insert the magic comment % !TEX encoding = UTF-8 Unicode at the beginning of your file. And if you want to use this encoding as a default for all your subsequent files, you can either use this line systematically (e.g. via a template) or open TeXShop's Preferences, its Document panel, and there select “Unicode (UTF-8)” in the “Encoding” section. – Franck Pastor Apr 20 '15 at 14:24
  • Thanks for your comment @fpast, so it should really be as a comment? That's a smart solution so as to not mess with the main preferences. David, leave an answer and I'll accept it. – Physics_maths Apr 20 '15 at 14:30

1 Answers1

8

Probably your file is not saved in UTF-8 encoding. Apparently TeXshop allows you to put

% !TEX encoding = UTF-8 Unicode

as the first line, although since it's now the 21st Century you should probably make that the editor default. This can be done in the main preferences of TeXShop in the Source panel (Encoding).

To summarize:

  • Install polyglossia (which should be installed in a full TeXLive (MacTeX))
  • install whichever fonts you fancy (Scheherazade for example)

Fonts in the Mac are installed in /Library/Fonts. The easiest way to do this is to use the Go menu in the finder, and enter /Library/Font when prompted. This will open the appropriate folder, and you can just drag the fonts into it.

Go to your TeX Editor preferences and make it

  • save things in UTF-8 Encoding!
  • Use XeLaTeX

Now you can type stuff in Kurdi/كوردی(Sorani/سۆرانی) and it should work out fine.

Alan Munn
  • 218,180
David Carlisle
  • 757,742