How to format LaTeX Arabic: write from right to left

Explain clearly which compilation engine should be used for LaTeX typesetting Arabic, how to use polyglossia and fontspec to set the language and fonts, how to correctly mix English paragraphs and formulas, and provide a checklist after compilation.

Key points of this article

  • Typesetting Arabic text must be compiled with XeLaTeX or LuaLaTeX. pdfLaTeX has weak support for Arabic glyphs and directions.
  • Use polyglossia to declare Arabic as another language, put the entire Arabic text into the arabic environment, and the direction will automatically switch from right to left.
  • Arabic fonts need to be specified separately with fontspec Script=Arabic. When the font is missing, letters cannot be concatenated correctly.
  • After compilation, check the spelling of letters, the direction of the whole sentence, the position of punctuation and the form of numbers, and compare it with the original manuscript paragraph by paragraph.

When writing papers, lecture notes, or bilingual materials, many people put both English and Arabic in LaTeX. The common problems are: Arabic letters are not written consecutively, the direction of the whole sentence is wrong, the punctuation is on the wrong side, and even the compilation directly reports an error. The root of the problem is that Arabic is written from right to left, and the letters will deform according to their location. A font that supports Arabic glyphs and special language settings are required. The processing method is different from Latin letters and Chinese.

This article talks about the specific setting method of Arabic in LaTeX. After reading, you can judge which compilation engine to use, set the language and font in the introduction area, mix Arabic paragraphs with English text, and check the compilation results item by item.

Should I change the engine for LaTeX Arabic typesetting? One sentence conclusion: Yes, compile with XeLaTeX or LuaLaTeX and switch languages via polyglossia.

your situationRecommended practicesreason
The main body of the document is in English, with only a few paragraphs in Arabic.XeLaTeX adds polyglossia, and puts Arabic paragraphs into the arabic environmentThe amount of configuration is small, and direction switching and font calling are relatively straightforward.
There is a lot of Arabic text, and the headers and table of contents should also be in Arabic.LuaLaTeX adds polyglossia and sets Arabic as the main languageThe direction and layout settings of the entire document are more complete
Arabic is mostly quotations or short wordsXeLaTeX, wrapping phrases with textarabic commandDo not interrupt the structure of English paragraphs
Only old templates of pdfLaTeX can be usedUse XeLaTeX to recompile, or convert the Arabic text into images and embed them first.pdfLaTeX requires additional macro packages and has weak support for glyph alignment and orientation.
Need to write LaTeX on the web page and export itFirst confirm the source code in the web editor, then download it to local compiler and checkThe preview on the web page cannot replace the local compilation results.

Before you start: Confirm these points first

1. Confirm the compilation engine. Arabic ligatures rely on the glyph table in the font, and XeLaTeX and LuaLaTeX can directly read OpenType fonts. If your editor defaults to pdfLaTeX, change it in the compilation settings first, otherwise the subsequent font settings will not take effect.

2. Prepare Arabic font. Amiri, Noto Naskh Arabic, and Scheherazade New are all open source fonts that support common Arabic glyphs. The font needs to be installed on the local machine or put into the project directory; when the font is missing, the compilation log will prompt that the font cannot be found or characters are missing.

3. Determine the main language of the document. If English is the main body and Arabic is the inserted content, use the default language to be English and Arabic as the other language. If the entire article is mainly in Arabic, Arabic must be set as the main language, and the direction of the header, page numbers, and table of contents will be affected.

4. Confirm the form of numbers and punctuation. Eastern Arabic numerals are commonly used in Arabic, and Western numerals are commonly used in English and scientific writing. If required by journals or school templates, ask first and then set the digital format in the language options.

5. Confirm the source file encoding. The source file is saved as UTF-8, and Arabic text can be pasted directly. If garbled characters appear after copying from other software, check the encoding settings of the editor first, and do not rush to change the command.

Steps to insert Arabic text into a LaTeX document

  1. Set the compilation engine. Select XeLaTeX or LuaLaTeX in the editor's compilation options, and use the same engine for every subsequent compilation.
  2. Load polyglossia in the introductory area. Write the load command, set the default language to English, and declare Arabic as other languages, so that Arabic paragraphs will be typeset according to Arabic rules.
  3. Define Arabic font. Use the new font command in the fontspec macro package to define a font family. Specify Script=Arabic in the parameters. The font name must be consistent with the name installed on the local machine, such as Amiri.
  4. Wrap Arabic paragraphs. The entire Arabic text is placed in the arabic environment, and the font defined in step 3 is used in the environment. Single words or phrases can be wrapped with the textarabic command.
  5. Process sentences adjacent to English and Arabic. English proper nouns and numbers remain in the default language, and a blank line is left between the Arabic paragraph and the English paragraph to reduce misalignment when switching directions.
  6. Handle Arabic text in formulas. The Arabic text in the mathematical environment must be wrapped with the text command and the Arabic font must be specified. Otherwise, the formulas will be rendered in mathematical fonts and the letters may not be written consecutively.
  7. Compile twice and check PDF. The first compile generates cross-references, the second compile updates the numbering and table of contents, and then goes through the Arabic passages page by page.

Check each item after completion

Check itemsHow to seeWhat to do if there is a problem
Whether the letters are connectedEnlarge the PDF to see if the Arabic letters are connected in the wordThe font does not support or Script=Arabic is not specified. Change the font and check the font name.
whole sentence directionThe sentence is read from right to left, and the order of the subject and modifying components is normal.Check whether the arabic environment is missing, or the Arabic text is wrapped in English paragraphs
punctuation positionAre question marks, commas, and periods on the correct side of the Arabic text?Place punctuation back within Arabic paragraphs to avoid crossing language boundaries
Numeric formWhether the number is Eastern Arabic numerals or Western numerals, consistent with the requirementsAdjust number forms in language options and unify full text
Compilation logAre there any warnings about font not found and missing characters?Install the font or specify the correct path in the font command, and then recompile
Compare with originalCompare the original text paragraph by paragraph to check for missing sentences, wrong words, and spelling of proper names.Arabic text generated by machine translation or OCR must be manually checked and cannot be delivered directly.

📊 Core comparison

Compilation engineArabic supportSuitable scene
XeLaTeXRead OpenType fonts directly. Arabic ligatures and directions are more mature for use with polyglossia.Papers and reports mainly in English with Arabic paragraphs inserted
LuaLaTeXOpenType fonts are also supported, and Lua scripts can be written to extend functions.Documents that are mainly in Arabic and have complex format requirements
pdfLaTeXRequires additional macro packages, weak font and orientation support, and some templates are incompatibleOnly suitable for maintaining old templates, not recommended for new documents

❓ Frequently Asked Questions (FAQ)

1. Why does pdfLaTeX report an error when compiling Arabic?

The font system of pdfLaTeX does not directly support Arabic OpenType glyphs. The common method relies on additional macro packages, and the compatibility and continuous writing effect are unstable. Changing to XeLaTeX or LuaLaTeX, combined with fontspec and polyglossia, can usually solve most errors.

2. Can Arabic and Chinese be used in the same document?

Can. Chinese is generally set through ctex or xeCJK, and Arabic is set through polyglossia and a separate font family. The two specify fonts separately and do not interfere with each other. If a font conflict occurs during compilation, first check whether the two sets of fonts are overwritten by the same command.

3. How to deal with Arabic references?

References can be managed with biblatex, indicating the language in the entries and having the styles arranged according to Arabic rules. The Arabic author's name and title should be checked with the original text to avoid inconsistencies in spelling and transliteration.

4. If I want to translate English LaTeX source code into Arabic, can I use OmniDoc?

OmniDoc supports document translation of LaTeX source code packages. You can upload the source code package at omnidoc.top, select the translation output and then download it. The translation results still need to be compiled locally with XeLaTeX or LuaLaTeX, and the Arabic direction, ligatures, and formulas must be checked page by page, and professional terminology must be checked by someone familiar with Arabic.

📝 Summary

The key to LaTeX Arabic typesetting is three things: switching to XeLaTeX or LuaLaTeX compilation, setting the language and font using polyglossia and fontspec respectively, and putting the Arabic paragraphs into the correct environment. After compilation, the documents are checked one by one according to spelling, direction, punctuation, numbers and comparison with the original manuscript. The document can be stably mixed with English and Arabic.

Open OmniDoc and edit, convert or translate your LaTeX document

Updated 2026-11-11