15

For typesetting arabic with LaTeX there are arabtex and arabi; for typesetting arabic with XeLaTeX there are arabxetex and polyglossia; but how to typeset arabic with LuaLaTeX, since neither of these packages/methods does not work? And there is definitely a way (with very nice results) as demonstrated in "Fonts" papers (PDF) from LuaTeX web page.

I've also found Khaled's lualatex-package package, but still no go.

Any suggestions?

2
  • It does not really answer your question, but I ended up using XeLaTeX as I also required support for arab.
    – cies
    Feb 15, 2012 at 8:06
  • Do you know Graham Douglas' great LuaTeX blog? readytext.co.uk/?cat=12
    – topskip
    Feb 15, 2012 at 8:14

2 Answers 2

11

It is because some works is in progress specially for the bidi package, on the other hand I am waiting for some of luatex bidi bugs getting fixed. you can test things if you want:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Script=Arabic]{font-name}
\usepackage{bidi}
\pagedir TRT\pardir TRT\bodydir TRT\textdir TRT
\begin{document}
%your Arabic text
\end{document}
4
  • Thanks, this solves part of the problem, i.e., direction of text. Unfortunately, direction applies to numbers too, making them wrong.
    – Meho R.
    Jun 19, 2011 at 10:06
  • for that you can use Khaled Hosny's experimental luadirections package which implements uni-bidi.
    – user9783
    Jun 19, 2011 at 10:26
  • Or I can use custom commands for numbers with corrected text directions. Again, thanks for pointing me in the right direction, much appreciated.
    – Meho R.
    Jun 19, 2011 at 13:27
  • Please can you add some comments to clear what each commend do?
    – bttX
    May 12, 2017 at 15:07
13

Updated Answer (2017-12-28)

% !TEX TS-program = lualatexmk
\documentclass{article}
\usepackage{fontspec}

\setmainfont[Ligatures=TeX]{Times New Roman}
\newfontfamily\arabicfont
    [Script=Arabic,     % to get correct arabic shaping
    Scale=1.2]          % make the arabic font bigger, a matter of taste
        {Arial}     % whatever Arabic font you like

\newcommand{\textarabic}[1]     % Arabic inside LTR
    {\bgroup\textdir TRT\arabicfont #1\egroup}
\newcommand{\n}         [1]     % for digits inside Arabic text
    {\bgroup\textdir TLT #1\egroup}
\newcommand{\afootnote} [1]     % Arabic footnotes
    {\footnote{\textarabic{#1}}}
\newenvironment{Arabic}     % Arabic paragraph
    {\textdir TRT\pardir TRT\arabicfont}{}

\begin{document}

English text ``\textarabic{جملة عربية وسط جملة إنجليزية}'' with Arabic in
between. English paragraph left aligned English paragraph left aligned English
paragraph left aligned English paragraph left aligned English paragraph left
aligned English paragraph left aligned English paragraph left aligned English
paragraph left aligned English paragraph left aligned English paragraph left
aligned English paragraph left aligned.

\begin{Arabic}
فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين \n{١٢٣٤٥} فقرة عربية
محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين
فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى
اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى
اليمين\afootnote{حاشية عربية.} فقرة عربية محاذاة إلى اليمين.
\end{Arabic}

\end{document}

Old Answer

Two days ago Khaled Hosny sent me this:

\documentclass{article}
\usepackage{fontspec}

\setmainfont[Ligatures=TeX]{Junicode}
\newfontfamily\arabicfont
    [Script=Arabic,        % to get correct arabic shaping
     Scale=1.2]            % make the arabic font bigger, a matter of taste
    {Scheherazade}         % whatever Arabic font you like

\newcommand{\textarabic}[1] % Arabic inside LTR
           {\bgroup\luatextextdir TRT\arabicfont #1\egroup}
\newcommand{\n}         [1] % for digits inside Arabic text
           {\bgroup\luatextextdir TLT #1\egroup}
\newcommand{\afootnote} [1] % Arabic footnotes
           {\footnote{\textarabic{#1}}}
\newenvironment{Arabic}     % Arabic paragraph
           {\luatextextdir TRT\luatexpardir TRT\arabicfont}{}

\begin{document}

English text ``\textarabic{جملة عربية وسط جملة إنجليزية}'' with Arabic in
between. English paragraph left aligned English paragraph left aligned English
paragraph left aligned English paragraph left aligned English paragraph left
aligned English paragraph left aligned English paragraph left aligned English
paragraph left aligned English paragraph left aligned English paragraph left
aligned English paragraph left aligned.

\begin{Arabic}
فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين \n{١٢٣٤٥} فقرة عربية
محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين
فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى
اليمين فقرة عربية محاذاة إلى اليمين فقرة عربية محاذاة إلى
اليمين\afootnote{حاشية عربية.} فقرة عربية محاذاة إلى اليمين.
\end{Arabic}

\end{document}

This probably is as uptodate as it gets atm.

8
  • The definition of \n and so \textarabic is wrong. See implementation of \LRE and \RLE macros in bidi package.
    – Simurgh12
    Apr 25, 2012 at 15:21
  • @Simurgh12 I don't know whether you could really say that they are "wrong". I am not an expert on this but I thought that this solution actually does not use bidi and thus does not use the bidi-commands \LRE and \RLE. But, as I said, I don't know -- it just works perfectly. May 5, 2012 at 13:56
  • @ClintEastwood: It does not work perfectly as you claim. For instance, try \n{\verb|\Hello|} with your given code/example above and see what happens. Also try \LRE{\verb|\Hello|} with bidi package in xelatex and see the results for yourself.
    – Simurgh12
    May 6, 2012 at 2:40
  • @Simurgh12: I tried both and got different sorts of error. In fact, a few weeks ago I tried to get bidi to work and failed. Thus, I was happy to receive the solution which I shared. Why don't you just tell us what you'd recommend? Couldn't you just give your answer to the initial question? May 7, 2012 at 11:00
  • What is the error that you get with bidi package in xelatex? You are the first person saying bidi failed to work. I support user9783 answer.
    – Simurgh12
    May 7, 2012 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .