1

We have many issues when using xcolor with right to left text (pdflatex and xelatex)
Colors bizarre results with right to left text

The answer suggest to use the command from fontspec package

{\addfontfeature{Color=red} colored text here } 

I thought if it is possible to change the definition of command \color to be the same as Color from fontpec we can solve those issues even partially

\documentclass{beamer}
\usepackage{fontspec}
\setmainfont[Script=Arabic]{Amiri} 
\usefonttheme{serif}


% redefine \color{#1} to be the same as \addfontfeature{Color=#1}  

\usepackage[rldocument]{bidi}

\begin{document}
\raggedleft

\begin{frame}{title}
\begin{enumerate}\raggedleft
\item
text from right to left \alert{text from right to left text from right to left 
text from right to left} out
\end{enumerate}

\end{frame}


\renewcommand{\alert}[1]{{\addfontfeature{Color=red}#1}}

\begin{frame}{title}

\begin{enumerate}\raggedleft
\item
text from right to left \alert{text from right to left text from right to left 
text from right to left} out
\end{enumerate}

\end{frame}

\end{document}

enter image description here

enter image description here

3

No, this is really not a good idea. \addfontfeature affects only fonts, not rules, not drawings like tikz. So in presentations you would e.g. loose all the frame colors:

\documentclass{article}
\usepackage{fontspec,tikz}
\setmainfont{TeX Gyre Heros}
\begin{document}
{\color{red}
some text in red
\rule{1cm}{1cm}
\tikz\draw[<->,red](0,0)--++(1,1);
}
\def\color#1{\addfontfeature{Color=#1}}
\color{red}
some text in red
\rule{1cm}{1cm}
\tikz\draw[<->,red](0,0)--++(1,1);
\end{document}

enter image description here

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.