2

This is a complement to these questions:

My aim is to create a macro like \color which can be used in RTL mode (right to left) and in all circumstances to color text and drawing stuff without issues:

Here my attempt (which use fontspec Color key to color text and normal \color to color rules and drawings but this need external markup ~ ~)

\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont{Amiri}

\usepackage[rldocument]{bidi}

\def\rtlcolor#1{%
\def~{\bgroup\color{#1}\let~\egroup}
\addfontfeature{Color=#1}
}

\begin{document}

Right to left text {\rtlcolor{red} RED TEXT ~\rule{5pt}{5pt}~ right to left text  
right to left text right to left text right to left text right to left text } out of group 

\end{document}

enter image description here

  • 2
    Why is switching to luatex not an option for you? You are now fighting since weeks with the insufficient rtf model of xelatex. – Ulrike Fischer Feb 4 at 11:04
  • Most of rtl writers use xelatex rather then lualatex because of the great support from bidi package – Salim Bou Feb 4 at 11:24
  • 2
    That's now. But seeing the lack of development in xetex/bidi/polyglossia compared to the changes in bidi/babel and the luatex engine I would say it would make more sense to spent your time to improve luatex. – Ulrike Fischer Feb 4 at 14:26

Your Answer

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

Browse other questions tagged or ask your own question.