> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/languages/05-arabic.md).

# Arabic

## Introduction

In this article we explain how to typeset Arabic using the [`arabtex`](https://ctan.org/pkg/arabtex?lang=en) package with `pdfLaTeX`. However, the underlying pdfTeX engine (software), which typesets/processes your pdfLaTeX document, has relatively limited support for typesetting complex-script languages such as [Arabic](https://en.wikipedia.org/wiki/Arabic), [Hebrew](https://en.wikipedia.org/wiki/Hebrew_language), [Devanagari](https://en.wikipedia.org/wiki/Devanagari) or [Malayalam](https://en.wikipedia.org/wiki/Malayalam). Typesetting such languages requires more complete support of Unicode-based text input, the use of OpenType fonts and other capabilities which are not present in pdf(La)TeX.

Many authors are mandated to use pdfLaTeX due to requirements of their workflow, but if you *are* able to choose the LaTeX compiler, **the modern approach to typesetting Arabic is to use XeLaTeX (XeTeX engine) or LuaLaTeX (LuaHBTeX engine)**. LuaLaTeX, via LuaHBTeX, provides the most advanced and complete TeX-based solutions for complex-script language typesetting. **See these pages about** [**polyglossia**](/latex/languages/01-multilingual-typesetting-on-overleaf-using-polyglossia-and-fontspec.md) **and** [**babel**](/latex/languages/02-multilingual-typesetting-on-overleaf-using-babel-and-fontspec.md).

### Notes on the arabtex package

Klaus Lagally started work on the `arabtex` package in 1991, primarily as a personal project—see [Appendix B of the package documentation](https://mirror.apps.cam.ac.uk/pub/tex-archive/language/arabic/arabtex/doc/pdf/arabdoc.pdf). Its genesis and early development predates the advent of pdfTeX by around 5 years and LuaHBTeX and XeTeX by more than a decade—and long before the rise of Unicode and OpenType fonts. The `arabtex` package is a tour-de-force of complex TeX programming, but many core component files now date from circa 2003, meaning that the age of the `arabtex` package can give rise to incompatibilities with current versions of LaTeX or LaTeX packages.

## A first arabtex example

The following basic example uses the `arabtex` package to typeset a single word in Arabic:

```latex
\documentclass[a4paper,10pt]{article}
\usepackage{arabtex}
\usepackage{utf8}
\setcode{utf8}
\begin{document}
Here is the word ``Arabic'' written in Arabic:  \<اَلْعَرَبِيَّةُ>. You can also use the command \verb|\RL{arabic text}| like this: \RL{اَلْعَرَبيَّةُ}.
\end{document}
```

[Open this `pdfLaTeX` and `arabtex` example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+Arabic+text+example\&snip=%5Cdocumentclass%5Ba4paper%2C10pt%5D%7Barticle%7D%0A%5Cusepackage%7Barabtex%7D%0A%5Cusepackage%7Butf8%7D%0A%5Csetcode%7Butf8%7D%0A%5Cbegin%7Bdocument%7D%0AHere+is+the+word+%60%60Arabic%27%27+written+in+Arabic%3A++%5C%3C%D8%A7%D9%8E%D9%84%D9%92%D8%B9%D9%8E%D8%B1%D9%8E%D8%A8%D9%90%D9%8A%D9%8E%D9%91%D8%A9%D9%8F%3E.+You+can+also+use+the+command+%5Cverb%7C%5CRL%7Barabic+text%7D%7C+like+this%3A+%5CRL%7B%D8%A7%D9%8E%D9%84%D9%92%D8%B9%D9%8E%D8%B1%D9%8E%D8%A8%D9%8A%D9%8E%D9%91%D8%A9%D9%8F%7D.%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![Example of Arabic typeset by arabtex](/files/yzxMbvif79656dF4qIQ4)

Note that the `*arabic text*` used with command `\RL{*arabic text*}` should not contain more than a single paragraph of right-to-left text.

### arabtex: transliteration or UTF-8 input

The `arabtex` package supports the ability to typeset Arabic text by writing it using a particular form of transliteration: representing Arabic text using the Latin script. Here's a fragment from an example in the `arabtex` documentation—note how the Arabic text is represented in Latin text, which is converted to Arabic:

```latex
\documentclass[12pt]{article}
\usepackage{arabtex}
\begin{document}
\setarab % choose the language specific conventions
\vocalize % switch diacritics for short vowels on
%\transtrue % display the transliteration
\arabtrue % print arabic text (on by default)
\centerline {\RL{^gu.hA wa-.himAruhu}} % typeset a centred line of Arabic text
\begin{RLtext}
fa-qAla lahu ^gu.hA:

.garIbuN 'amruka yA .sadIqI!
'a-tu.saddiqu al-.himAra wa-tuka_d_dibunI?
\end{RLtext}
\end{document}
```

[Open this `pdfLaTeX` and `arabtex` example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+Arabic+text+example\&snip=%5Cdocumentclass%5B12pt%5D%7Barticle%7D%0A%5Cusepackage%7Barabtex%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetarab+%25+choose+the+language+specific+conventions%0A%5Cvocalize+%25+switch+diacritics+for+short+vowels+on%0A%25%5Ctranstrue+%25+display+the+transliteration%0A%5Carabtrue+%25+print+arabic+text+%28on+by+default%29%0A%5Ccenterline+%7B%5CRL%7B%5Egu.hA+wa-.himAruhu%7D%7D+%25+typeset+a+centred+line+of+Arabic+text%0A%5Cbegin%7BRLtext%7D%0Afa-qAla+lahu+%5Egu.hA%3A%0A%0A.garIbuN+%27amruka+yA+.sadIqI%21%0A%27a-tu.saddiqu+al-.himAra+wa-tuka_d_dibunI%3F%0A%5Cend%7BRLtext%7D%0A%5Cend%7Bdocument%7D)

This example produces the following output:

![Example of Arabic typeset by arabtex](/files/FvjCMikikZNwr049jwKo)

If we want `arabtex` to use actual Arabic text as input, not transliterated Latin text, we have to tell `arabtex` to use UTF-8 input instead, by writing

```latex
\usepackage{utf8}
\setcode{utf8}
```

The `utf8` package is part of the `arabtex` package.

## A second arabtex example

The following example contains a more substantial piece of Arabic text which also contains some words in English:

```latex
\documentclass[a4paper,10pt]{article}
\usepackage{arabtex}
\usepackage{utf8}
\begin{document}
\setcode{utf8}
Here is the word ``Arabic'' written in Arabic:  \<اَلْعَرَبِيَّةُ>. You can also use the command \verb|\RL{arabic text}| like this: \RL{اَلْعَرَبيَّةُ}.

\vspace{10pt}
Here is a larger section of Arabic, containing some words in English within the \verb|\LR| command:

\vspace{10pt}
\begin{RLtext}
يعود تاريخ علوم الحاسوب إلى اختراع أول حاسوب رقمي حديث. فقبل العشرينات من القرن العشرين، كان مصطلح حاسوب \LR{Computer} يشير إلى أي أداة بشرية تقوم بعملية الحسابات. ما هي القضايا أو الأشياء التي يمكن لآلة أن تحسبها باتباع قائمة من التعليمات مع ورقة وقلم، دون تحديد للزمن اللازم ودون أي مهارات أو بصيرة (ذكاء)؟ وكان أحد دوافع هذه الدراسات هو تطوير آلات حاسبة \LR{computing machines} يمكنها إتمام الأعمال الروتينية والعرضة للخطأ البشري عند إجراء حسابات بشرية.
خلال الأربعينات، مع تطوير آلات حاسبة أكثر قوة وقدرة حسابية، تتطور مصطلح حاسوب ليشير إلى الآلات بدلا من الأشخاص الذين يقومون بالحسابات. وأصبح من الواضح أن الحواسيب يمكنها أن تقوم بأكثر من مجرد عمليات حسابية وبالتالي انتقلوا لدراسة تحسيب أو التحسيب بشكل عام. بدأت المعلوماتية وعلوم الحاسب تأخذ استقلالها كفرع أكاديمي مستقل في الستينات، مع إيجاد أوائل أقسام علوم الحاسب في الجامعات وبدأت الجامعات تعطي إجازات في هذه العلوم [1].
\end{RLtext}
\end{document}
```

[Open this `pdfLaTeX` and `arabtex` example in Overleaf.](<https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+more+complete+arabtex+example\&snip=\documentclass\[a4paper,10pt]{article}&#xA;\usepackage{arabtex}&#xA;\usepackage{utf8}&#xA;\begin{document}&#xA;\setcode{utf8}&#xA;Here+is+the+word+``Arabic''+written+in+Arabic:++\\\<اَلْعَرَبِيَّةُ\>.+You+can+also+use+the+command+\verb|\RL{arabic+text}|+like+this:+\RL{اَلْعَرَبيَّةُ}.+&#xA;&#xA;\vspace{10pt}&#xA;Here+is+a+larger+section+of+Arabic,+containing+some+words+in+English+within+the+\verb|\LR|+command:&#xA;&#xA;\vspace{10pt}&#xA;\begin{RLtext}&#xA;يعود+تاريخ+علوم+الحاسوب+إلى+اختراع+أول+حاسوب+رقمي+حديث.+فقبل+العشرينات+من+القرن+العشرين،+كان+مصطلح+حاسوب+\LR{Computer}+يشير+إلى+أي+أداة+بشرية+تقوم+بعملية+الحسابات.+ما+هي+القضايا+أو+الأشياء+التي+يمكن+لآلة+أن+تحسبها+باتباع+قائمة+من+التعليمات+مع+ورقة+وقلم،+دون+تحديد+للزمن+اللازم+ودون+أي+مهارات+أو+بصيرة+(ذكاء)؟+وكان+أحد+دوافع+هذه+الدراسات+هو+تطوير+آلات+حاسبة+\LR{computing+machines}+يمكنها+إتمام+الأعمال+الروتينية+والعرضة+للخطأ+البشري+عند+إجراء+حسابات+بشرية.&#xA;خلال+الأربعينات،+مع+تطوير+آلات+حاسبة+أكثر+قوة+وقدرة+حسابية،+تتطور+مصطلح+حاسوب+ليشير+إلى+الآلات+بدلا+من+الأشخاص+الذين+يقومون+بالحسابات.+وأصبح+من+الواضح+أن+الحواسيب+يمكنها+أن+تقوم+بأكثر+من+مجرد+عمليات+حسابية+وبالتالي+انتقلوا+لدراسة+تحسيب+أو+التحسيب+بشكل+عام.+بدأت+المعلوماتية+وعلوم+الحاسب+تأخذ+استقلالها+كفرع+أكاديمي+مستقل+في+الستينات،+مع+إيجاد+أوائل+أقسام+علوم+الحاسب+في+الجامعات+وبدأت+الجامعات+تعطي+إجازات+في+هذه+العلوم+\[1].+&#xA;\end{RLtext}&#xA;\end{document}>)

## An arabtex example also using babel

The following examples uses `arabtex` together with the `babel` and `inputenc` packages, for reasons that will be noted below.

```latex
\documentclass[11pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{arabtex}
%\usepackage[LAE]{fontenc} %Not needed due to [arabic] option of the babel package
\usepackage[arabic]{babel}
\title{
    \Huge\textsc{اللغة العربية}
}
\author{سالم البوزيدي}
\begin{document}
\maketitle
\tableofcontents
\chapter{علوم الحاسوب}
\section{تاريخ}
\begin{otherlanguage}{arabic}
يعود تاريخ علوم الحاسوب إلى اختراع أول حاسوب رقمي حديث. فقبل العشرينات من القرن العشرين، كان مصطلح حاسوب \textLR{Computer} يشير إلى أي أداة بشرية تقوم بعملية الحسابات. ما هي القضايا أو الأشياء التي يمكن لآلة أن تحسبها باتباع قائمة من التعليمات مع ورقة وقلم، دون تحديد للزمن اللازم ودون أي مهارات أو بصيرة (ذكاء)؟ وكان أحد دوافع هذه الدراسات هو تطوير آلات حاسبة \textLR{computing machines} يمكنها إتمام الأعمال الروتينية والعرضة للخطأ البشري عند إجراء حسابات بشرية.
خلال الأربعينات، مع تطوير آلات حاسبة أكثر قوة وقدرة حسابية، تتطور مصطلح حاسوب ليشير إلى الآلات بدلا من الأشخاص الذين يقومون بالحسابات. وأصبح من الواضح أن الحواسيب يمكنها أن تقوم بأكثر من مجرد عمليات حسابية وبالتالي انتقلوا لدراسة تحسيب أو التحسيب بشكل عام. بدأت المعلوماتية وعلوم الحاسب تأخذ استقلالها كفرع أكاديمي مستقل في الستينات، مع إيجاد أوائل أقسام علوم الحاسب في الجامعات وبدأت الجامعات تعطي إجازات في هذه العلوم [1].
\end{otherlanguage}
\end{document}
```

[Open this Arabic text example in Overleaf](<https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Typesetting+Arabic+with+pdfLaTeX\&snip=\documentclass\[11pt,a4paper]{report}&#xA;\usepackage\[utf8]{inputenc}&#xA;\usepackage{arabtex}&#xA;%\usepackage\[LAE]{fontenc}+%Not+needed+due+to+\[arabic]+option+of+the+babel+package&#xA;\usepackage\[arabic]{babel}&#xA;\title{&#xA;++++\Huge\textsc{اللغة+العربية}&#xA;}&#xA;\author{سالم+البوزيدي}&#xA;\begin{document}&#xA;\maketitle&#xA;\tableofcontents&#xA;\chapter{علوم+الحاسوب}&#xA;\section{تاريخ}&#xA;\begin{otherlanguage}{arabic}&#xA;يعود+تاريخ+علوم+الحاسوب+إلى+اختراع+أول+حاسوب+رقمي+حديث.+فقبل+العشرينات+من+القرن+العشرين،+كان+مصطلح+حاسوب+\textLR{Computer}+يشير+إلى+أي+أداة+بشرية+تقوم+بعملية+الحسابات.+ما+هي+القضايا+أو+الأشياء+التي+يمكن+لآلة+أن+تحسبها+باتباع+قائمة+من+التعليمات+مع+ورقة+وقلم،+دون+تحديد+للزمن+اللازم+ودون+أي+مهارات+أو+بصيرة+(ذكاء)؟+وكان+أحد+دوافع+هذه+الدراسات+هو+تطوير+آلات+حاسبة+\textLR{computing+machines}+يمكنها+إتمام+الأعمال+الروتينية+والعرضة+للخطأ+البشري+عند+إجراء+حسابات+بشرية.&#xA;خلال+الأربعينات،+مع+تطوير+آلات+حاسبة+أكثر+قوة+وقدرة+حسابية،+تتطور+مصطلح+حاسوب+ليشير+إلى+الآلات+بدلا+من+الأشخاص+الذين+يقومون+بالحسابات.+وأصبح+من+الواضح+أن+الحواسيب+يمكنها+أن+تقوم+بأكثر+من+مجرد+عمليات+حسابية+وبالتالي+انتقلوا+لدراسة+تحسيب+أو+التحسيب+بشكل+عام.+بدأت+المعلوماتية+وعلوم+الحاسب+تأخذ+استقلالها+كفرع+أكاديمي+مستقل+في+الستينات،+مع+إيجاد+أوائل+أقسام+علوم+الحاسب+في+الجامعات+وبدأت+الجامعات+تعطي+إجازات+في+هذه+العلوم+\[1].+&#xA;\end{otherlanguage}&#xA;\end{document}>)

![LanguageEx2.png](/files/YuOZqpmmcjtq0VQHU2FM)

### Input encoding

To support a variety of input encodings for different groups of languages and/or on different computer platforms LaTeX employs the `inputenc` package. Prior to the release of TeX Live 2018, using UTF-8 encoded text with pdfLaTeX required the `inputenc` package by writing

```latex
\usepackage[utf8]{inputenc}
```

in your document's preamble.

As noted in the Overleaf blog post [TeX Live upgrade—September 2019](https://www.overleaf.com/blog/tex-live-upgrade-september-2019), LaTeX has switched to UTF-8 as the default input encoding; consequently, it is now not *usually* necessary to explicitly write `\usepackage[utf8]{inputenc}` if you are using a post-2018 release of TeX Live. However, for the above example writing `\usepackage[utf8]{inputenc}` is still required.

### Language-specific document elements

The `arabic` option of the `babel` package provides support for the Arabic language:

```latex
\usepackage[arabic]{babel}
```

which includes bidirectional typesetting and use of Arabic names for document elements. If you need to insert some `Latin text` inside your Arabic document, you use the `\textLR{...}` command; for example, by writing

```latex
\textLR{Latin text}
```

### Font encoding

In addition to using the correct *input* encoding, typesetting a LaTeX document, containing Arabic text, requires fonts with the appropriate correct *output* encoding to provide the glyphs (shapes) which represent typeset Arabic. Typesetting the example above needs the equivalent of writing

```latex
\usepackage[LAE]{fontenc}
```

but, as noted in this [reply on tex.stackexchange](https://tex.stackexchange.com/a/518665), using the `arabic` option of `babel` results in loading the required `LAE` encoding files `laeenc.def` and `laeenc.dfu`.

## Further reading

For more information see

* [Multilingual typesetting on Overleaf using polyglossia and fontspec](/latex/languages/01-multilingual-typesetting-on-overleaf-using-polyglossia-and-fontspec.md)
* [Multilingual typesetting on Overleaf using babel and fontspec](/latex/languages/02-multilingual-typesetting-on-overleaf-using-babel-and-fontspec.md)
* [Supporting modern fonts with XƎLaTeX](/latex/fonts/03-xelatex.md)
* [Typesetting quotations and quotation marks](/latex/languages/04-typesetting-quotations.md)
* [International language support](/latex/languages/03-international-language-support.md)
* [Chinese](/latex/languages/06-chinese.md)
* [French](/latex/languages/07-french.md)
* [German](/latex/languages/08-german.md)
* [Greek](/latex/languages/09-greek.md)
* [Italian](/latex/languages/10-italian.md)
* [Japanese](/latex/languages/11-japanese.md)
* [Korean](/latex/languages/12-korean.md)
* [Portuguese](/latex/languages/13-portuguese.md)
* [Russian](/latex/languages/14-russian.md)
* [Spanish](/latex/languages/15-spanish.md)
* [The not so short introduction to LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [LaTeX/Internationalization on WikiBooks](http://en.wikibooks.org/wiki/LaTeX/Internationalization)
* [LaTeX/Special\_Characters on WikiBooks](http://en.wikibooks.org/wiki/LaTeX/Special_Characters)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/languages/05-arabic.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
