3

I want to place the Persian translation of quran package =\quransurahfa*[1] right below the original text=\quransurah*[1] of this code :

\documentclass[b5paper,11pt]{memoir}
\usepackage[left=1.8cm,right=1.8cm,top=3cm]{geometry}
\usepackage{arabxetex}
\usepackage[trans=fa]{quran}
\usepackage{xepersian}
\settextfont[Scale=0.7]{Yas}

\newfontfamily\Amiri[Script=Arabic]{Amiri}


\begin{document}
\begin{arab}
\noindent\Amiri\quransurah*[1]
\end{arab}
\noindent
\quransurahfa*[1]
\end{document}

which produces : enter image description here

to appear like this:

enter image description here

10
  • 1
    There is no way (at least no easy way) to make linebreak of translation respect linebreak of the original text.
    – touhami
    May 31, 2019 at 15:09
  • @touhami If sacrifice this feature, how could just make the lines combinated, not exactly word by word or number by number? May 31, 2019 at 17:37
  • you can try something like this. I'll give it a try, but not to night :-) sorry!
    – touhami
    May 31, 2019 at 17:43
  • All right, thanks. May 31, 2019 at 17:48
  • Maybe something could be done with the expex package. But \quransurah is not expandable, so I think you'd need to enter your text directly for it to work. Jun 1, 2019 at 7:05

2 Answers 2

2

Here's an attempt at doing this with the expex package which is especially for linguistics.

Updated answer using \quranayah

You can use \quranayah[1][1] to insert each ayah. The problem is that the whole ayah is placed in a box which can't be broken across lines. So if you leave things justified you will get ugly overfull or underfull boxes everywhere. You could also try using \raggedleft but this doesn't look great either. My best option is to use a combination of \quranayah and manually broken lines as shown in the following MWE. I've adjusted a few other spacing settings to improve the output.

MWE

\documentclass{article}
\usepackage{xepersian}
\settextfont{Yas}

\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\usepackage[trans=fa]{quran}
\usepackage{expex}
\makeatletter
\lingset{%
  everygl=\def\qt@no##1{ \hfill ##1},
  everygla=\arabicfont\large\rule{0pt}{5ex},
  everyglb=\footnotesize,
  glrightskip=0pt,
  glhangstyle=none,
  glspace=.5em plus 3em minus .15em
}
\makeatother

\pagestyle{empty}
\begin{document}

\begingl
  \gla
    \quranayah*[1][1]
    \quranayah*[1][2]
    \quranayah*[1][3]
    \quranayah*[1][4]
    \quranayah*[1][5]
    {اهدِنَا الصِّراطَ} {المُستَقيمَ \hfill ﴿٦﴾}
    \quranayah*[1][7]
    //
  \glb
    \quranayahfa*[1][1]
    \quranayahfa*[1][2]
    \quranayahfa*[1][3]
    \quranayahfa*[1][4]
    \quranayahfa*[1][5]
    {ما را به راه راست} {هدايت فرما، \hfill (6)}
    \quranayahfa*[1][7]
    //
\endgl

\end{document}

MWE output

Original answer

Sorry that I've probably lined up the words wrong as I don't understand Arabic or Persian.

One issue is that I'm having trouble changing the line spacing. It seems to be the same issue as here. I've used the same work-around as in that question.

There are lots of options for controlling these structures in expex. Have a look at §9 of the manual.

MWE

I used the Qur'an text and Farsi translation from qurantext-simple.def and qurantext-fa.translation.def respectively.

I gave up at ayah 5 because ayah 6 was too confusing for me to decide what should go under what :).

I was unable to get it working with the quran package for the text. I think this is because \quransurah is not expandable.

\documentclass{article}
\usepackage{xepersian}
\settextfont{Yas}

\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\usepackage{expex}
\lingset{everygla=\arabicfont\large\rule{0pt}{25pt}, everyglb=\footnotesize,
  glwordalign=center}

\begin{document}

\begingl
  \gla بِسمِ اللَّهِ الرَّحمٰنِ الرَّحيمِ ۝١
    الحَمدُ لِلَّهِ رَبِّ العالَمينَ ۝٢
    الرَّحمٰنِ الرَّحيمِ ۝٣
    مالِكِ يَومِ الدّينِ ۝٤
    إِيّاكَ نَعبُدُ وَإِيّاكَ نَستَعينُ ۝٥
    //
  \glb {به نام} خداوند رحمتگر مهربان (١)
    ستايش خدايى {را كه پروردگار} جهانيان، (٢)
    رحمتگر مهربان، (٣)
    {[و] خداوند} روز جزاست. (٤)
    {[بار الها] تنها تو را} مى‌پرستيم، {و تنها از تو يارى} مى‌جوييم. (٥)
    //
\endgl

\end{document}

MWE output

7
  • Thank you. Again, well done. I'll check it out soon. Jun 4, 2019 at 16:57
  • Dear @DavidPurton , this solution produces very good-looking results, however interacting with the text to adjust exactly which word should sit in the right place is exhausting. To expose my standpoint, I will post it as an update to your answer so that i can ask you a question on it. Jun 4, 2019 at 20:40
  • You're right, the result isn't favorable. I will delete the answer since you have included the idea in your updated answer. Thank you again for your time. Jun 5, 2019 at 6:36
  • @AlirezaFarhadiK., I think you are going to struggle to get a completely automatic outcome without some manual intervention. Maybe you could type some an occasional ayah with manual breaks? Jun 5, 2019 at 7:09
  • Like what ? Does that solve the justifying issue? Jun 5, 2019 at 9:13
1

Here is an answer. (i don't have Yas font so Amiri is used for both Arabe and Persian).

\documentclass[b5paper,11pt]{memoir}
\usepackage[left=1.8cm,right=1.8cm,top=3cm]{geometry}
\usepackage{arabxetex}
\usepackage[trans=fa]{quran}
\usepackage{xepersian}
\settextfont[Scale=.7]{Amiri}

\newfontfamily\Amiri[Script=Arabic]{Amiri}

\newif\ifwecanrepeat
\newsavebox\quranar
\newsavebox\quranfr
\newsavebox\qurantemp

\makeatletter 
\newcommand{\quransurahAF}[1][\qt@surah@default]{%
\setbox\quranar=\vbox{%
  \begin{arab}
    \noindent\Amiri\quransurah*[#1]
  \end{arab}}%
\setbox\quranfr=\vbox{%
  \noindent
  \quransurahfa*[#1]}%
\loop
  \ifvoid\quranar
    \wecanrepeatfalse\unvbox\quranfr
  \else\ifvoid\quranfr
    \wecanrepeatfalse\unvbox\quranar
  \else
    \wecanrepeattrue
    \setbox\qurantemp=\vsplit\quranar to \baselineskip \unvbox\qurantemp
    \setbox\qurantemp=\vsplit\quranfr to \baselineskip \unvbox\qurantemp
  \fi\fi
\ifwecanrepeat\repeat}
\makeatother

\begin{document}
\quransurahAF[97]
\end{document}
2
  • Dear @touhami, usually the number of characters of the translated text exceed the original one, so they wont end at the same time (especially for long texts e.g. \quransurahAF[2] in the code) . Do you think is it possible to have the numbers placed below each other? Jun 1, 2019 at 13:50
  • @AlirezaFarhadiK. Sorry, but no.
    – touhami
    Jun 1, 2019 at 16:13

You must log in to answer this question.

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