bidi使用未使用或的解决方案进行更新babel

bidi使用未使用或的解决方案进行更新babel

如何在 ACM 模板中编写乌尔都语?以下是Github这里是 背页

答案1

bidi使用未使用或的解决方案进行更新babel

考虑到您只需要偶尔插入乌尔都语单词,这实际上可能是您的最佳选择。它干扰最小,并且所有字体都与默认acmart包相同。它只处理英语 LTR 段落中的内联乌尔都语。经过一些调整,我甚至可以让它在 Overleaf 上运行(参见注释掉的行)。

%\def\normalfont{}% add to compile on Overleaf
\RequirePackage[no-math]{fontspec}
\documentclass[format=acmsmall,review=false,screen=true]{acmart}
\newfontfamily\urdufont{Noto Naskh Arabic}[Script=Arabic,Language=Urdu]
\ifxetex
  \TeXXeTstate=1
  \DeclareTextFontCommand{\texturdu}{\beginR\urdufont\aftergroup\endR}
\fi
\ifluatex
  \DeclareTextFontCommand{\texturdu}{\textdir TRT\urdufont}
\fi
%\let\copyright\textcopyright% add to compile on Overleaf
\begin{document}
\acmJournal{TWEB}
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmDOI{0000001.0000001}
\title{Article Title}
\author{John Doe}
\email{[email protected]}
\begin{abstract}
  Abstract text goes here.
\end{abstract}
\maketitle
\section{Article body starts here}
English paragraph with inline Urdu \texturdu{اُردُو} English text.
\end{document}

使用未使用bidi包的解决方案进行更新

这是一个使用babel而不是 的解决方案bidi。它与xelatex和 一起使用lualatex,但要小心,因为babel的 bidi 支持尚不成熟。

此外,如果您打算提交这篇文章,我真的怀疑期刊是否会喜欢它......

\documentclass[format=acmsmall,review=false,screen=true]{acmart}
\usepackage[nil,bidi=default]{babel}
\usepackage[no-math]{fontspec}
\babelprovide[import=ur]{urdu}
\babelprovide[import=en-US,default]{american}
\babelfont{rm}[Numbers=Lining]{Linux Libertine O}
\babelfont{sf}{Linux Biolinum O}
\babelfont[urdu]{rm}{Noto Naskh Arabic}
\babelfont[urdu]{sf}{Noto Sans Arabic}
\makeatletter
% fix mweights package bold font selection for using fontspec
\def\bfseries@rm{bx}
\def\bfseries@sf{bx}
\makeatother

\begin{document}
\acmJournal{TWEB}
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmDOI{0000001.0000001}
\title{Article Title}
\author{John Doe}
\email{[email protected]}
\begin{abstract}
  Abstract text goes here.
\end{abstract}
\maketitle

\section{Article body starts here}

English paragraph with inline Urdu
\foreignlanguage{urdu}{اُردُو}
English text.

Display maths:

\[ \sum_{i=1}^n \sin n\phi \]

Right to left Urdu paragraph with inline English:

\selectlanguage{urdu}

اُردُو \foreignlanguage{american}{English text} اُردُو

\selectlanguage{american}
\end{document}

在此处输入图片描述


使用包的原始示例bidi(breaks \maketitle

您想要的 MWE 示例可能会有所帮助,但也许这可以帮助您入门。

我无法开始polyglossia工作,因为fontspec之后的加载fontenc会更改默认编码,并且您会丢失libertine中设置的字体acmart.cls。也许有办法解决这个问题,其他人可以提出建议。目前,我之前已经加载fontspec(使用no-math选项)\documentclass并编写了自定义字体更改宏。

注意:我不知道如果您向期刊提交文章这会产生什么影响。

更新:我刚刚在 Overleaf 上测试了它,发现它由于过时的软件包而无法工作bidifontspec请参阅答案底部的解决方法。

\RequirePackage[no-math]{fontspec}
\documentclass[format=acmsmall,review=false,screen=true]{acmart}
\newfontfamily\urdufont{Amiri}[Script=Arabic,Language=Urdu]
\usepackage{bidi}
\newcommand\texturdu[1]{\RLE{\setnonlatin\urdufont#1}}
\newcommand\textenglish[1]{\LRE{\setlatin\fontencoding{T1}\libertine#1}}
\newenvironment{urdu}{\setRL\setnonlatin\urdufont}{}
\newenvironment{english}{\setLR\setlatin\fontencoding{T1}\libertine}{}
\begin{document}
English paragraph with inline Urdu \texturdu{اُردُو} English text.

Display math:

\[ \sum_{i=1}^n \sin n\phi \]

Right to left Urdu paragraph with inline English:

\begin{urdu}
  اُردُو \textenglish{English text} اُردُو
\end{urdu}
\end{document}

在此处输入图片描述


Overleaf 上过时软件包的解决方法:

\def\normalsize{} % Workaround for outdated fontspec on Overleaf
\RequirePackage[no-math]{fontspec}
\documentclass[format=acmsmall,review=false,screen=true]{acmart}
\newfontfamily\urdufont{Noto Naskh Arabic}[Script=Arabic,Language=Urdu]
\usepackage{bidi}
\makeatletter % Start workaround for outdated bidi package on Overleaf
\newcommand{\setnonlatin}{\@Latinfalse}
\newcommand{\setlatin}{\@Latintrue}
\setlatin
\makeatother % End workaround for outdated bidi package on Overleaf
\newcommand\texturdu[1]{\RLE{\setnonlatin\urdufont#1}}
\newcommand\textenglish[1]{\LRE{\setlatin\fontencoding{T1}\libertine#1}}
\newenvironment{urdu}{\setRL\setnonlatin\urdufont}{}
\newenvironment{english}{\setLR\setlatin\fontencoding{T1}\libertine}{}
\begin{document}
\thispagestyle{empty}
English paragraph with inline Urdu \texturdu{اُردُو} English text.

Display math:

\[ \sum_{i=1}^n \sin n\phi \]

Right to left Urdu paragraph with inline English:

\begin{urdu}
  اُردُو \textenglish{English text} اُردُو
\end{urdu}
\end{document}

答案2

该解决方案可以正常工作:

\documentclass[format=acmsmall, review=false, screen=true]{acmart}
\usepackage[english]{babel}
\let\latinencoding\relax
\usepackage{fontspec}
\babelprovide[import=ur]{urdu}
\babelprovide[import=en-US,default]{american}
\babelfont{rm}{Linux Libertine O}
\babelfont{sf}{Linux Biolinum O}
\babelfont[urdu]{rm}{Jameel Noori Nastaleeq}
\babelfont[urdu]{sf}{Jameel Noori Nastaleeq}
\makeatletter
% fix mweights package bold font selection for using fontspec
\def\bfseries@rm{bx}
\def\bfseries@sf{bx}
\makeatother

\begin{document}
\acmJournal{TWEB}
\acmVolume{9}
\acmNumber{4}
\acmArticle{39}
\acmDOI{0000001.0000001}
\title{Article Title}
\author{John Doe}
\email{[email protected]}
\begin{abstract}
 Abstract text goes here.
\end{abstract}
\maketitle

\section{Article body starts here}

English paragraph with inline Urdu
\foreignlanguage{urdu}{اُردُو}
English text.

Display maths:

\[ \sum_{i=1}^n \sin n\phi \]

Right to left Urdu paragraph with inline English:

\selectlanguage{urdu}

اُردُو \foreignlanguage{american}{English text} اُردُو

\selectlanguage{american}
\end{document}`

相关内容