如何在 XeLaTeX 中添加与英语句子一致的阿拉伯语?

如何在 XeLaTeX 中添加与英语句子一致的阿拉伯语?

我目前正在写一本书,需要在文档中的英文句子中添加阿拉伯语单词。例如:“这个词(阿拉伯语单词)是...的定义。”我尝试使用LR{}和,{\afont "arabicword"}但都不起作用。

\documentclass[12pt]{book}
\usepackage[arabic,main=english]{babel}


\usepackage[sc,compact,explicit]{titlesec} % Titlesec for configuring the header

\usepackage{auto-pst-pdf} % Vectorian Ornaments XeTeX auxiliary (from: 
https://tex.stackexchange.com/questions/253477/how-to-use-psvectorian-with-pdflatex)
\usepackage{psvectorian} % Vectorian Ornaments

 \let\clipbox\relax % PSTricks (used by PSVectorian) already defines a \clipbox, so 
 we need this workaround
 \usepackage{adjustbox} % Adjustbox to rescale the ornaments (scalebox breaks 
 titlesec for some reason...)

\newcommand{\otherfancydraw}{% Defining a command to shorten things
\begin{adjustbox}{max height=0.5\baselineskip}% Rescaling to have height of 
0.5\baselineskip
\raisebox{-0.25\baselineskip}{
\rotatebox[origin=c]{45}{% And rotating 90 degrees
\psvectorian{7}% Ornament n° 26 
(http://melusine.eu.org/syracuse/pstricks/vectorian/psvectorian.pdf)
}}%
\end{adjustbox}%
}

% A command to create a rule centered vertically on the text (from: 
https://tex.stackexchange.com/questions/15119/draw-horizontal-line-left-and-right-of- 
some-text-a-single-line/15122#15122)
\newcommand*\ruleline[1]{\par\noindent\raisebox{.8ex}{\makebox[\linewidth]. 
{\hrulefill\hspace{1ex}\raisebox{-.8ex}{#1}\hspace{1ex}\hrulefill}}}
\usepackage{fontspec}
\titleformat% Formatting the header
{\chapter} % command
[block] % shape - Only managed to get it working with block
{\normalfont\bfseries\sc\huge} % format - Change here as needed
{\centering Chapter \thechapter\\} % The Chapter N° label
{0pt} % sep
{\centering \ruleline{\otherfancydraw}\\ % The horizontal rule
\centering #1} % And the actual title
\usepackage{lmodern} % monospace font
\usepackage[T1]{fontenc}
\renewcommand{\ttdefault}{lmtt} % MONO Latin Modern Font % T1 encoding of cmtt font 
s\renewcommand{\rmdefault}{lmr} % SERIF Latin Modern Font % T1 encoding of cmr font 
st\renewcommand{\sfdefault}{lmss} % SANS Latin Modern F
\newcommand{\q}[1]{>>\textit{#1}<<}
\newcommand{\prefacename}{Preface}
\newenvironment{preface}{
\vspace*{\stretch{2}}
{\noindent \bfseries \Huge \prefacename}
\begin{center}
    % \phantomsection \addcontentsline{toc}{chapter}{\prefacename} % enable this if 
 you want to put the preface in the table of contents
    \thispagestyle{plain}
\end{center}%
}
{\vspace*{\stretch{5}}}


\usepackage{arabxetex}



 \begin{document}
 Test \LR{arabic word here} test test
 \end{document}

然而,这似乎不起作用,我编译时加载了英文单词,但没有阿拉伯语单词。

答案1

对于简短的阿拉伯语文本,您只需要:

\documentclass[12pt]{book}

\usepackage[bidi=default, english]{babel}
\babelfont[arabic]{rm}{FreeSerif}

\begin{document}
One two \foreignlanguage{arabic}{لاثة أربعة} five six.
\end{document}

在此处输入图片描述

还:

• 不要 加载fontenc, 这 是 为了pdflatex, 不是xelatex.

arabxetex没有必要。

相关内容