Monatsarchiv für Dezember 2009

Hagen Fritsch

Arabic Script in LaTeX

We arrived in the 21st century and one would assume that with famous software like LaTeX you’d go write the document in whatever language you like, use Unicode or UTF-8 as character encoding for your text (without even thinking about it) and it just works. Unfortunately Knuth was one these people who thought no one would ever need more than 256 characters, so unless you’re typing ASCII, you’re screwed.

I already figured out, that you can use \usepackage[utf8]{inputenc} and German Umlauts start working, but you don’t get full utf8 coverage, as lots of chars Neo allows me to type (like • or → or …) are just not available.

It took me a couple of hours to figure out, how to get Arabic letters into my latex document, because even with the ucs package they won’t work as the corresponding character definition page uni-6.def is missing. Then I stumbled upon ArabTex (in texlive-lang-arab) which is awesome and has thousands of customizable ways to create Arabic script from several input encodings or transliteration modules. So I wrote my script after reading the documentation:

\documentclass{article}
\usepackage{utf8}
\usepackage{arabtex}

\begin{document}
\setcode{utf8}
\setarab
\RL{ سلام }
\end{document}

However, my document still would not compile:

(/usr/share/texmf-texlive/tex/latex/arabtex/utf8.sty
! Undefined control sequence.
l.19 \UsePackage
{utfcode}

After some trial and error it turned out, that you need to use arabtex before using utf8 and then you’re all set :-)

\usepackage{arabtex}
\usepackage{utf8}

سلام