13

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?

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

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}
  • 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 '11 at 10:06
  • for that you can use Khaled Hosny's experimental luadirections package which implements uni-bidi. – user9783 Jun 19 '11 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 '11 at 13:27
  • Please can you add some comments to clear what each commend do? – bttX May 12 '17 at 15:07
12

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.

  • The definition of \n and so \textarabic is wrong. See implementation of \LRE and \RLE macros in bidi package. – Simurgh12 Apr 25 '12 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. – ClintEastwood May 5 '12 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 '12 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? – ClintEastwood May 7 '12 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 '12 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.