# Create an adapted \color macro for RTL mode (pdflatex and xelatex)

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}

• Most of rtl writers use xelatex rather then lualatex because of the great support from bidi package – Salim Bou Feb 4 at 11:24