How can I change the color of Arab word endings without losing the connections? It's just ugly and loses readability. I'm using Tex Live 2012: arabxetex with xelatex but any package and/or engine is welcome.








4 Answers 4


A workaround is to insert Zero Width Joiner character around the text break area, this would force final/initial forms. For most fonts with should be OK, though it would break contextual alternates in more advanced fonts, but the text should still be readable. Other than that, there is no way to switch color without breaking text into two parts in XeTeX.



\newcommand{\colorred}[1]{\char"200D\textcolor{red}{\char"200D #1}}





sample output

P.S. just use regular color package, \addfontfeature{} loads (and switches to) a new font each time it is called, witch is an overkill for just switching colors.


To obtain colored vowels in Arabic script, we can use ArabTeX with the acolor.sty. The following example shows how to use it:


\node[text=#2,opacity=0.5] (ombre)
at (0,0) {#3};
\node[text=#1] at (-.089,.089) {#3};


\fcolorbox{blue!30!black}{lightyellow!47!white}{\ombre[blue!30!black][yellow]{\Huge \setnashbf \RL{\fullvocalize \acolor{diacritics}{poppyred} \acolor{letters}{darkgreen}     $\bigstar$ bismi  al-ll_ahi \acolor{diacritics}{poppyredd}  al-rra.h-m_ani \acolor{diacritics}{poppyreddd}  al-rra.hImi $\bigstar $}}}


\fcolorbox{blue!30!black}{lightyellow!47!white}{\ombre[blue!30!black][yellow]{\LARGE \setnashbf \RL{ \fullvocalize \acolor{diacritics}{blue} \acolor{letters}{darkgreen} 
$\ast$ wa bihi na-s-ta-`Inu wa  al-.ha--mdu li-ll_ahi a-lla_dI yassaranA \acolor{hamza}{purple} lil-'a`--mAli al-.s.sAli.haTi $\ast$ }}}


Using the built-in mechanism of ArabTeX, you can indicate by a hyphen (which becomes invisible) that a given letter should consider itself medial, albeit standing at a word border.


should make do in your example. However the choice of the font may change the result significantly. (I don't know, if the two forms of the ha are acceptable for the context of the question.) See also my answer here.


You can find the package acolor.sty on the internet or you can copy & paste the following file and put it in arabtex package in your texmf or project folder:

% acolor.sty
% ArabTeX macros for coloring the graphemes
% 06.11.2001
% (c) Karel Mokry
%     student of Mathematics
%     Charles University in Prague
%     [email protected]
%     http://artax.karlin.mff.cuni.cz/~jazyk/
% (c) Otakar Smrz
%     Institute of Formal and Applied Linguistics
%     Charles University in Prague
% Karel Mokry:
%   16.11.2000 version 1.0
%     - first released version
%   06.11.2001 version 1.1
%     - problems with output fixed -- looked 'broken'
%     - output from verses.sty was full of garbage
%     [ reported by Daddi Addoun Yacine ]
% Otakar Smrz:
%   23.05.2007 version 1.2
%     - reimplemented using xcolor
%     - new syntax and extended sets
%     - local scope of coloring
%   19.06.2007 version 1.3
%     - \acoloron, \noacolor, \acolorlet, and \acolor
%       are now allowed as part of the input notation
%     [ reported by Torsten Nieland ]
%     - explicit \nospace is generally needed in case
%       of intervening space between groups of glyphs
%     - minor bug fix in acolor names


\ProvidesPackage{acolor}[2007/06/19 Colors for ArabTeX]


% putting acolor in effect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% defining acolor settings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


    \ifthenelse{\equal{#1}{everything}}{\acolor{letters}   {#2}%
                                     \acolor{initial} {#2}%
                                     \acolor{medial}  {#2}%
                                     \acolor{final}   {#2}}{%
                                        \acolor{shadda}    {#2}}{%
    \ifthenelse{\equal{#1}{vowelmarks}}{\acolor{fatha}   {#2}%
                                        \acolor{kasra}   {#2}%
                                        \acolor{damma}   {#2}%
                                        \acolor{quran}   {#2}%
                                        \acolor{ammad}   {#2}%
                                        \acolor{bars}    {#2}}{%

% acmd.sty
% ArabTeX command processing
% 20.08.2003

\all@wcmd \acoloron         \all@wtw@ \acolorlet
\all@wcmd \noacolor         \all@wtw@ \acolor

% aboxes.sty
% ArabTeX
% deposit character into output box
% called in HMODE
% Version 28.05.2003

% dynamic definitions for Arabic
{\catcode `\^ 7 \catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
\gdef \def@arabaccent {% define accent macros for Arabic
\gdef \put@fatha     {\put@acc@hi {\a@color {fatha}     {\char \a@fatha}      }}
\gdef \put@damma     {\put@acc@hi {\a@color {damma}     {\char \a@damma}      }}
\gdef \put@kasra     {\put@acc@lo {\a@color {kasra}     {\char \a@kasra}      }}
\gdef \put@shadda    {\put@acc@hi {\a@color {shadda}    {\char \a@shadda}     }}
\gdef \put@hamza     {\put@hi     {\a@color {hamza}     {\char \a@hamza}      }}
\gdef \put@hamzalo   {\put@lo     {\a@color {hamza}     {\char \a@hamza}      }}
\gdef \put@madda     {\put@hi     {\a@color {madda}     {\a@madda@up}         }}
\gdef \put@sukun     {\put@acc@hi {\a@color {sukun}     {\char \a@sukun}      }}
\gdef \put@wasla     {\put@acc@hi {\a@color {wasla}     {\char \a@wasla}      }}
\gdef \put@fathatan  {\put@acc@hi {\a@color {fatha}     {\char \a@fathatan}   }}
\gdef \put@dammatan  {\put@acc@hi {\a@color {damma}     {\char \a@dammatan}   }}
\gdef \put@kasratan  {\put@acc@lo {\a@color {kasra}     {\char \a@kasratan}   }}
\gdef \put@fathaspec {\put@acc@hi {\a@color {quran}     {\char \a@quran@alif} }}
\gdef \put@kasraspec {\put@acc@lo {\a@color {quran}     {\char \a@quran@alif} }}
\gdef \put@dammaspec {\put@acc@hi {\a@color {quran}     {\char \a@quran@alif} }}
\gdef \put@ammad     {\put@acc@hi {\a@color {ammad}     {\char \a@ammad}      }}
\gdef \put@zwarakay  {\put@acc@hi {\a@color {zwarakay}  {\char \a@zwarakay}   }}
\gdef \put@barslo    {\put@lo     {\a@color {bars}      {\char \a@bars}       }}
\gdef \put@kh@hamza  {\put@hi     {\a@color {hamza}     {\char \a@hamza}      }}
\gdef \put@kl@hamza  {\put@lo     {\a@color {hamza}     {\char \a@hamza}      }}
\gdef \put@kh@hamz@s {\put@hi     {\a@color {hamza}     {\char \a@hamz@s}     }}
\gdef \put@kl@hamz@s {\put@lo     {\a@color {hamza}     {\char \a@hamz@s}     }}

}}% end of dynamic definitions for Arabic

% awrite.sty
% ArabTeX
% basic contextual analysis
% called in HMODE
% Version 05.06.2003

\def \lig@iso #1*#2*{% isolated shape                        % m1 * m2 *
\a@color{isolated}{\put@lig@skel 0\a@f@iso #1*#2*\a@norm }}

\def \lig@end #1*#2*{% final shape                           % m1 * m2 *
\a@color{final}{\put@lig@skel 1\a@f@end #1*#2*}}

\def \ac@iso #1*{% isolated shape                        % m *
\a@color{isolated}{\put@skel 0\a@f@iso #1*\a@norm }}

\def \ac@end #1*{% final shape                           % m *
\a@color{final}{\put@skel 1\a@f@end#1*}}

\def \ac@mid #1*{% medial shape                          % m *
\a@color{medial}{\put@skel 2\a@f@mid #1*}}

\def \ac@beg #1*{% initial shape                         % m *
\a@color{initial}{\put@skel 3\a@f@beg #1*\a@norm }}


%\a@create{hamza} \a@create{kasra} \a@create{damma}    \a@create{fatha}
%\a@create{madda} \a@create{quran} \a@create{shadda}   \a@create{sukun}
%\a@create{wasla} \a@create{ammad} \a@create{zwarakay} \a@create{bars}




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .