5

I've had some problems with ^s when using arabxetex in footnotes. Transliteration and conversion to Arabic script work fine in the main text, but in footnotes they do not. All other letters seem to work fine.

\documentclass{article}


\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Numbers=OldStyle]{Brill}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.3]{Scheherazade}
\usepackage{arabxetex}

\begin{document}

Here it works: \textarab[trans]{^s}

Here it doesn't:
\footnote{\textarab[trans]{^s}}
\end{document}
5

The \textarab command changes category codes so it can't be used in the argument to another command.

There's a way out by using \scantokens. A quick redefinition can be obtained with the regexpatch command.

\documentclass{article}

\usepackage{fontspec}
\usepackage{arabxetex}
\usepackage{regexpatch}

\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Brill}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.3]{Scheherazade}

\makeatletter
\xpatchcmd*{\text@arab}{#2}{\scantokens{#2\noexpand}}{}{}
\makeatother

\setlength{\textheight}{2cm} % just to have a smaller picture
\begin{document}


Here it works: \textarab[trans]{^s}X\textarab{^s}X

Here too\footnote{\textarab[trans]{^s}X\textarab{^s}X}
\end{document}

enter image description here

The X's I added are just to ensure that no spurious space creeps in.

Here's the full redefinition in case you can't use regexpatch.

\documentclass{article}

\usepackage{fontspec}
\usepackage{arabxetex}

\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Brill}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.3]{Scheherazade}

\makeatletter
\renewcommand\text@arab[2][\ax@mode]{%
  \edef\@tempa{#1}%
  \def\ax@lang{arab}%
  \ax@ismode@defined{\@tempa}%
  \ifax@mode@defined
    \ifx\@tempa\ax@mode@trans
      {\ax@trans@style\addfontfeature{Mapping=arabtex-trans-\ax@trans@convention}\scantokens{#2\noexpand}}%
    \else
      \ifx\@tempa\ax@mode@utf
        \RL{\arabicfont\utf@fontfeature\scantokens{#2\noexpand}}%
      \else
        \RL{\arabicfont\addfontfeature{Mapping=arabtex-\ax@font@allah-\@tempa}\scantokens{#2\noexpand}}%
      \fi
    \fi
  \else
    \PackageWarning{arabxetex}{Mode \@tempa\ not defined, defaulting to \@ax@mode}%
    \RL{\arabicfont\addfontfeature{Mapping=arabtex-\ax@font@allah-\ax@mode}\scantokens{#2\noexpand}}%
  \fi
  \egroup}
\makeatother

\setlength{\textheight}{2cm} % just to have a smaller picture
\begin{document}


Here it works: \textarab[trans]{^s}X\textarab{^s}X

Here too\footnote{\textarab[trans]{^s}X\textarab{^s}X}
\end{document}

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.