我编写了一本阿拉伯语-英语双语词典,
对于词典中的每个术语,阿拉伯语术语右对齐,英语术语左对齐,
我使用 Hfill 来处理小文本,但如果英文文本很长,我该怎么做
\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}
答案1
在你的情况下,表格更合适,collcell
包用于收集单元格内容以\textenglish
对其应用命令
\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}
更新
另一种解决方案是使用\hangindent
和\hangafter
来控制右侧的缩进量
\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}
答案2
这是基于 Overleaf 词典模板的示例。我只是复制了\newcommand{\entry}[4]
并调整了字符呈现的方向。
对于西方读者来说,这种顺序可能有点不常见。不知道您是否会以这种方式在阿拉伯语-英语词典中呈现它。如果您想要 4 个组(由变量 #1 .. #4 表示)的不同顺序,请在定义中更改它们的顺序\newcommand
。如果您想要更少的顺序,比如 3,请将选项设置为[3]
并删除不需要的(比如\hfill\LR{(#2)}\
)。
这样你就可以建立一本字典。
另一种选择可能是使用表格作为布局手段,例如在最左边的列中使用阿拉伯语单词。
\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}
结果: