Skip to main content
To write an Arabic document in LaTeX, compile with XeLaTeX using fontspec and polyglossia (\setdefaultlanguage{arabic} plus an Arabic font declared with \newfontfamily\arabicfont[Script=Arabic]{Amiri}), or compile with LuaLaTeX using babel (bidi=basic) and the HarfBuzz renderer. This fontspec setup requires XeTeX or LuaTeX for OpenType Arabic shaping. Under XeLaTeX, polyglossia loads bidi automatically for right-to-left (RTL) paragraphs, page layout, and section numbering, and localizes document elements such as the table of contents heading (المحتويات) and \today.
xelatex-arabic.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
Set [Script=Arabic] on \newfontfamily\arabicfont so OpenType Arabic letter joining, ligatures, and diacritics (harakat) are active. In the declaration above, omitting [Script=Arabic] makes fontspec select Latin script features for Amiri.

Mixing Arabic, English, and numerals

For English text in an Arabic document, declare \setotherlanguage{english} and optionally use \setmainfont{...} to choose the Latin font.
  • Wrap short Latin phrases, acronyms, or left-to-right ranges (such as 0--9) in \textenglish{...} so bidirectional ordering stays intact.
  • Wrap multi-sentence English passages in \begin{english}...\end{english} so the text reads left to right.
  • When English is the main language and Arabic is secondary (\setdefaultlanguage{english} and \setotherlanguage{arabic}), use \textarabic{...} for inline Arabic and \begin{Arabic}...\end{Arabic} (capital A) for Arabic paragraphs. polyglossia uses capital Arabic for the environment name to avoid colliding with LaTeX’s \arabic counter command.
With the default Arabic locale, polyglossia uses Eastern Arabic numerals (٠–٩) for generated numbers such as section counters and dates. Pass numerals=maghrib or numerals=western to \setdefaultlanguage after any locale option to display those numbers with Western digits (0–9). The module also accepts calendar (gregorian, hijri, or islamic) and regional month-name locale options (default, mashriq, libya, algeria, tunisia, morocco, or mauritania).
arabic-mixed-english.tex

Alternative setup: LuaLaTeX with babel

If your project already uses LuaLaTeX (for example with Lua-based packages or templates built around babel), configure RTL layout with bidi=basic and load your Arabic font through LuaTeX’s HarfBuzz shaper ([Renderer=HarfBuzz]):
lualatex-arabic-babel.tex
The layout=tabular option switches Babel’s tabular handling in right-to-left text from its default mixed mode to an all right-to-left mode. With this Babel setup, section numbers use Western digits and digits in the source print as typed.

Choosing an Arabic font

Choose a Unicode OpenType font that covers the Arabic characters in your document. If you share a project across Linux, macOS, and Windows machines, stick to open fonts such as Amiri or the Noto Arabic families rather than OS-bundled fonts like Traditional Arabic or Geeza Pro.

Common mistakes

  • Compiling with pdfLaTeX: fontspec stops immediately with Fatal Package fontspec Error: The fontspec package requires either XeTeX or LuaTeX. Switch the compiler to XeLaTeX (for polyglossia) or LuaLaTeX (for babel).
  • Using Latin Modern without an Arabic font family: With the default Latin Modern main font and no Arabic font family, polyglossia reports Package polyglossia Error: The current main roman font, lmroman10-regular, does not contain the "Arabic" script!.
  • Omitting [Script=Arabic] in the XeLaTeX example: Without this option, fontspec selects Latin script features for the Amiri family declared in the example.
  • Writing \begin{arabic} instead of \begin{Arabic}: In polyglossia, the Arabic paragraph environment is capitalized (Arabic) because \arabic is reserved for LaTeX counter formatting.
  • Leaving Latin ranges unboxed in RTL text: Writing (0--9) directly inside an Arabic paragraph can invert the order of the digits; wrap it as (\textenglish{0--9}).

In LaTeX Cloud Studio

LaTeX Cloud Studio compiles with TeX Live 2026 (full distribution), which includes polyglossia, bidi, babel, Amiri, Noto Naskh Arabic, and Noto Sans Arabic. Each project’s LaTeX Engine setting under Settings -> General defaults to Auto (Recommended); select XeLaTeX for the polyglossia examples or LuaLaTeX for the babel example, and your explicit choice is kept. If your document needs a custom Arabic font outside the preinstalled set, upload the .ttf or .otf files into your project and load them with fontspec. Ready to write an Arabic document in the browser? Start from the Basic Article template in LaTeX Cloud Studio and replace main.tex with whichever complete example above fits your setup.