# Coloring Arab suffix without losing connection

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.

\documentclass{article}

\usepackage{arabxetex}

\newcommand{\colorred}[1]{{\addfontfeature{Color=FF00FF}#1}}

\begin{document}

\textarab[voc]{kitab\colorred{hA}}

\textarab[voc]{kitabhA}

\end{document}

-

## 2 Answers

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.

\documentclass{article}

\usepackage{xcolor}
\usepackage{arabxetex}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

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

\begin{document}

\textarab[voc]{kitab\colorred{hA}}

\textarab[voc]{kitabhA}

\end{document}


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.

-

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.

kitabu-\textcolor{red}{-hA}


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.

-