1

I'm using pandoc to generate PDF files and I've installed MiKTeX for latex libraries.

I have a .tex file contains Arabic and English charachters. when I compile the file it generates a PDF file without arabic charachters.
here's the command I execute:

pandoc --latex-engine=xelatex khaled.tex -o khaled.pdf

and here's the tex file content:

\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}
  • 2
    You are compiling with XeLaTeX but using \luatextextdir which is a LuaTeX command. I would recommend compiling with XeLaTeX and using polyglossia (which loads the bidi package) to deal with the language commands instead of using your own commands. – Alan Munn Sep 4 '17 at 0:12
  • What error messages do you get? Did you look at them? Can you include the contents of the generated .log file? Also, can you remove any previously generated PDF and try again, to make sure that a PDF is even generated in the first place? Your file doesn't compile for me because \luatextextdir and \luatexpardir are undefined… but maybe they are for you? See what the errors say. – ShreevatsaR Sep 4 '17 at 0:13
  • Offtopic: interesting fact about Unicode: {١} ف displays in my browser with two opening braces { and {, even though it contains one opening { and one closing }. – ShreevatsaR Sep 4 '17 at 5:21
  • @AlanMunn thanks for your instant replay, but pardon me I'm new to this stuff, I don't know how to use polyglossia while compiling? – Mohamed-aaa-Omran Sep 4 '17 at 18:07
  • @ShreevatsaR Thanks for your reply, from the log I've found that the font isn't on my machine and I've changed it to Amiri but I've encountered an error too. khaled.tex 21 Undefined control sequence. \textarabic #1->\bgroup \luatextextdir TRT\arabicfont #1\egroup l.21 ...عربية وسط جملة إنجليزية} How could I configure \luatextextdir and \luatexpardir? I'm totally novice at this topic :( – Mohamed-aaa-Omran Sep 4 '17 at 20:21
1

I'de like to thank @Alan Munn and @ShreevatsaR and @khaled Hosny for putting me on the road. I asked this question with zero knowledge in LaTeX and after 6 days in reading and trial&error, I've gathered enough information to lead the way :)

Solution:
first thing I did is using packages that are compatible with the XeLaTeX enging. I used \usepackage{polyglossia}

and finally passing the parameter lang:ar here is the full command line I've used:
pandoc --latex-engine=xelatex -V mainfont:"Amiri" -V lang:ar -V dir:rtl -H include.tex khaled.md -o khaled.pdf

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.