I have this example
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{bidi}
\setmainfont{Amiri}
\parindent=0pt
\begin{document}
{\color{red} text from left to right text from left to right \par
text from left to right text from left to right }
\hrulefill
\setRTL
\color{red} text from right to left text from right to left
\par text from right to left text from right to left \normalcolor
\hrulefill
{\color{red} text from right to left text from right to left \par
text from right to left text from right to left}
\hrulefill
{before \color{red} text from right to left text from right to left \par
text from right to left text from right to left}
\end{document}
Color of text in ltr (left to right) is fine, but in rtl effects of \color
is confusing, also the text before \color
is colored! look like the command is applied from the beginning to the end of the paragraph without regard of command position.
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{bidi}
\setmainfont{Amiri}
\parindent=0pt
\begin{document}
\setRTL
{\leavevmode\color{red} text from right to left text from right to left \par
text from right to left} text from right to left \par
text from right to left text from right to left
\end{document}
Update 29/06/2018
With \addfontfeature{Color=red}
(command from fontspec
package) the problem can be solved like that
\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{bidi}
\setmainfont{Amiri}
\parindent=0pt
\begin{document}
\setRTL
before {\addfontfeature{Color=red} text from right to left text from right to left \par
text from right to left} text from right to left \par
text from right to left text from right to left
\end{document}
My aim is to find a method directly with xcolor
( or color
) package without reliance on package fontspec
.
\textcolor{red}{....}
or\leavevmode\color{red}.....
so the colour change is inside the paragraph (there are multiple issues with using\color
in vertical mode which are not really solvable without changing the underlying tex mechanisms.\color
command is also colored, I need onlly text inside braces to be colored.