2

I work on a bilingual dictionary, Arabic-English,

for each term in the dictionary, the arabic term is aligned to right, when the english is left,

I use Hfill for small texts, but if the english text is long, How can I do this

    \documentclass[a4paper,xelatex,ja=standard, enablejfam=true, jbase=8pt, nomag]{book}
\usepackage[margin=2cm,columnsep=5pt]{geometry} 
\usepackage{multicol}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.4pt}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setmainfont[Ligatures=TeX,Mapping=arabicdigits]{Amiri}
\setsansfont[Script=Arabic,Scale=0.8, Mapping=arabicdigits]{Amiri}
\setsansfont[Script=Latin,Scale=0.8, Mapping=arabicdigits]{Arial}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.2, Mapping=arabicdigits]{Amiri}

\begin{document}

\begin{Arabic} \textbf{قَبِلَ بِـ ( فعل ): - وافَقَ على} \hfill\LR{- content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take } \end{Arabic}

\begin{Arabic} \textbf{قَبِلَ بِـ ( فعل ): - وافَقَ على} \hfill\LR{- content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take } \end{Arabic}

\begin{Arabic} \textbf{قَبِلَ بِـ ( فعل ): - وافَقَ على} \hfill\LR{- content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take } \end{Arabic}

\begin{Arabic} \textbf{قَبِلَ بِـ ( فعل ): - وافَقَ على} \hfill\LR{- content oneself with; accede to } \end{Arabic}

\begin{Arabic} \textbf{قَبِلَ بِـ ( فعل ): - وافَقَ على} \hfill\LR{- content oneself with; accede to } \end{Arabic}

\end{document}

enter image description here

campa
  • 31,130
  • Welcome fo TeX.SE ! // As I understand it you want to create a dictionary. A way to do it I found at Overleaf: https://www.overleaf.com/latex/examples/dictionary-template/pdztbwjxrpmz . Click "View source" and may be copy the content to your Latex editor. // Key seems to be \newcommand{\entry}. As is you enter 4 groups of information, starting with the word of language-1. / Find examples for such \entry statements there, too. // At least this one solves the problem of too long text entries ;-) – MS-SPO Aug 17 '21 at 18:52
  • // See also "Bilingual dictionary typeset in LaTex" in https://tex.stackexchange.com/questions/1319/showcase-of-beautiful-typography-done-in-tex-friends/58218#58218 – MS-SPO Aug 17 '21 at 18:54
  • Thanks a lot, I already use given dictionary template, I have problem to align Dictionary entry as Arabic for the right, where the english text is aligned to the right. – linuxscout Aug 17 '21 at 21:06

2 Answers2

1

In your case a tabular is more suitable, collcell package is used to collect cell contents to applies \textenglish command on them

\documentclass[a4paper]{book}
\usepackage[margin=2cm,columnsep=5pt]{geometry} 
\usepackage{collcell,array}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.4pt}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.2, Mapping=arabicdigits]{Amiri} \newfontfamily\englishfont{Arial}

\newcolumntype{R}{>{\bfseries}Wr{4cm}} \newcolumntype{E}{>{\raggedright\arraybackslash\collectcell\textenglish}p{11cm}<{\endcollectcell}}

\begin{document}

\begin{tabular}{RE} قَبِلَ بِـ ( فعل ): - وافَقَ على &

  • content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take\

قَبِلَ بِـ ( فعل ): - وافَقَ على &

  • content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take\

قَبِلَ بِـ ( فعل ): - وافَقَ على &

  • content oneself with; accede to\

\end{tabular}

\end{document}

enter image description here

Update

Another solution using \hangindent and \hangafter to controls the amount of indentation from right side

\documentclass[a4paper]{book}
\usepackage[margin=2cm,columnsep=5pt]{geometry} 
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.4pt}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.2, Mapping=arabicdigits]{Amiri} \newfontfamily\englishfont{Arial}

\newbox\arabbox \newdimen\arabboxwd \newdimen\tempwd

\newcommand{\entry}[2]{% \setbox\arabbox\hbox{\bfseries#1}% \arabboxwd=\wd\arabbox% \advance\arabboxwd by 2ex% \tempwd=\linewidth% \advance\tempwd by -\arabboxwd% \begin{english} \hangindent=-\arabboxwd \hangafter=-1 \noindent\hbox to 0pt{\hskip\tempwd\hskip2ex\textarabic{\box\arabbox}\hss}% #2\par \end{english} }

\begin{document}

\entry% {قَبِلَ بِـ ( فعل ): - وافَقَ على} {- content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take}

\entry% {قَبِلَ بِـ ( فعل ): - وافَقَ على} {- content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take text text text text text text text text text text text text text text text text text text text text text}

\entry% {قَبِلَ بِـ ( فعل ): - وافَقَ على} {- content oneself with; accede to}

\end{document}

enter image description here

Salim Bou
  • 17,021
  • 2
  • 31
  • 76
0

Here is an example, based on the Overleaf dictionary template. I just copied the \newcommand{\entry}[4] and adapted the direction of character presentation.

For a western reader the order may be a bit uncommon. Don't know if you would present it in an Arabic-English dictionary this way. If you want a different order of the 4 groups (indicated by variables #1 .. #4), change their order in the \newcommand definition. If you want less, say 3, set the options to [3] and delete what's not needed (say \hfill\LR{(#2)}\).

This way you can build a dictionary.

An alternative might be using tables as a layout means, e.g. with the arabic word in the leftmost column.

\documentclass[a4paper,xelatex,ja=standard, enablejfam=true, jbase=8pt, nomag]{book}
\usepackage[margin=2cm,columnsep=5pt]{geometry} 
\usepackage{multicol}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.4pt}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\setmainfont[Ligatures=TeX,Mapping=arabicdigits]{Amiri}
\setsansfont[Script=Arabic,Scale=0.8, Mapping=arabicdigits]{Amiri}
\setsansfont[Script=Latin,Scale=0.8, Mapping=arabicdigits]{Arial}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.2, Mapping=arabicdigits]{Amiri}

% --- adapted from Overleaf template ---------------- \newcommand{\entry}[4]{\markboth{#1}{#1}\textbf{#1}\ \hfill\LR{(#2)}\ \hfill\LR{\textit{#3}}\ $\bullet$\ \hfill\LR{#4}}

\begin{document} \begin{Arabic} % --- one example --------------- \entry{ - وافَقَ على}{how to hyphenate this word or phrase}{type of word}{content oneself with; accede to; accept to; agree to; approve of; assent to; consent to; settle for; subscribe to; admit; confirm; endorse; ratify; sanction; take }

\end{Arabic}

\end{document}

Result:

Result

MS-SPO
  • 11,519