9

Please consider the MWE below:

MWE - scenario 1

\documentclass[demo]{scrartcl}
\usepackage{polyglossia}
\setmainlanguage[locale=mashriq,numerals=mashriq,abjadjimnotail=true]{arabic}
% \newfontfamily\arabicfont[Script=Arabic,Ligatures=TeX,Mapping=arabicdigits]{Simplified Arabic}
% \setsansfont[Script=Arabic,Ligatures=TeX,Mapping=arabicdigits]{Simplified Arabic}
\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits,Ligatures=TeX]{Simplified Arabic}
\setsansfont[Script=Arabic,Mapping=arabicdigits,Ligatures=TeX]{Simplified Arabic}

\usepackage[style=numeric,sorting=none,backend=biber]{biblatex}
\DefineBibliographyStrings{english}{%
  references = {المراجع}}
\makeatletter
\def\abx@comma{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{،}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{ibnsina,
    author = {{ابن سينا}},
    year = {{١٤١٧}},
    title = {السماع الطبيعى من كتاب الشفاء},
    publisher = {دار المناهل},
    location = {لبنان، بيروت}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

هنا نص بالعربية مع ارقام هندي ١، ٢، ٣، الخ ومع الواصلة، واحدة - واثنتان -- وثلاثة ---.

احد المراجع\parencite{ibnsina}.

\printbibliography
\end{document}

Output -- scenario1
enter image description here

MWE -- scenario2

\newfontfamily\arabicfont[Script=Arabic,Ligatures=TeX,Mapping=arabicdigits]{Simplified Arabic}
\setsansfont[Script=Arabic,Ligatures=TeX,Mapping=arabicdigits]{Simplified Arabic}
% \newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits,Ligatures=TeX]{Simplified Arabic}
% \setsansfont[Script=Arabic,Mapping=arabicdigits,Ligatures=TeX]{Simplified Arabic}

Output -- scenario2
enter image description here

I get either of these two effects depending on which argument is passed at the end of the Arabic font definitions. In scenario 1 last argument is Ligatures=TeX, whereas in scenario 2 the last argument is Mapping=arabicdigits.

Question
Is there any way to keep both Hindi numbers and the TeX ligatures of en dash and em dash effects at the same time?

Notes

  • compiled by xetex
  • \textemdash, \textendash are obvious answers but I don't want to resort to them in Rt-to-Lt document as it will produce messy text script
  • undesired output is marked with yellow in the screenshots
9

You can use only one mapping file at a time; so the solution is to merge the map files.

Prepare a file texarabicdigits.map containing

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "TeX-text"
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D           <>  U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>  U+2014  ; --- -> em dash

U+0027          <>  U+2019  ; ' -> right single quote
U+0027 U+0027   <>  U+201D  ; '' -> right double quote
U+0022           >  U+201D  ; " -> right double quote

U+0060          <>  U+2018  ; ` -> left single quote
U+0060 U+0060   <>  U+201C  ; `` -> left double quote

U+0021 U+0060   <>  U+00A1  ; !` -> inverted exclam
U+003F U+0060   <>  U+00BF  ; ?` -> inverted question

; additions supported in T1 encoding
U+002C U+002C   <>  U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C   <>  U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E   <>  U+00BB  ; >> -> RIGHT POINTING GUILLEMET

; from arabicdigits.map
U+0030 <> U+0660 ;
U+0031 <> U+0661 ;
U+0032 <> U+0662 ;
U+0033 <> U+0663 ;
U+0034 <> U+0664 ;
U+0035 <> U+0665 ;
U+0036 <> U+0666 ;
U+0037 <> U+0667 ;
U+0038 <> U+0668 ;
U+0039 <> U+0669 ;

Now run

teckit_compile texarabicdigits

which will produce a file texarabicdigits.tec. Keep it in the same directory as your main file. Now the following test file

\documentclass[demo]{scrartcl}
\usepackage{polyglossia}
\setmainlanguage[locale=mashriq,numerals=mashriq,abjadjimnotail=true]{arabic}
\newfontfamily\arabicfont[Script=Arabic,Mapping=texarabicdigits]{Scheherazade}
\newfontfamily\arabicfontsf[Script=Arabic,Mapping=texarabicdigits]{Scheherazade}

\usepackage[style=numeric,sorting=none,backend=biber]{biblatex}
\DefineBibliographyStrings{english}{%
  references = {المراجع}}
\makeatletter
\def\abx@comma{\ifdim\lastkern>\z@\unkern\fi\abx@puncthook{،}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{ibnsina,
    author = {{ابن سينا}},
    year = {{١٤١٧}},
    title = {السماع الطبيعى من كتاب الشفاء},
    publisher = {دار المناهل},
    location = {لبنان، بيروت}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

هنا نص بالعربية مع ارقام هندي ١، ٢، ٣، الخ ومع الواصلة، واحدة - واثنتان -- وثلاثة ---.

احد المراجع\parencite{ibnsina}.

\printbibliography
\end{document}

will produce the following output

enter image description here

The .tec and .map file can then be moved in a local TeX tree.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.