2

I would like to demonstrate declension in the Arabic language by coloring a single vowel or letter. I found some solutions to color a single letter, however the connections would break. So again I'm looking for a solution that can color a vowel individually and a letter individually. I am currently using XeTeX and the polyglossia package. And input arabic text using: \textarabic. I don't mind switching to another package, since I'm still just a beginner using this package anyway.

Any help would be appreciated. Thanks in advance.


@KhaledHosny I indeed tried to create a hack myself, unfortunately I was only able to do it for the last letter and also made use of the ZWJ. I didn't know how to enforce the final form of the letter though. Also for vowels I got stuck in how to do that. Here is the macro I created:

\newcommand{\mymacro}[1]{%
\StrRight{#1}{1}[\lastletter]%
\StrBefore{#1}{\lastletter}[\rest]%
\rest\char"200D{\color{red}\lastletter\char"200D}
}

I use it like this:\textarabic{\mymacro{اَلْمَدِينَة}} But at the end I get a colored ة

When trying to color a single vowel, it just doesn't appear.

  • 1
    Unfortunately, there is no way in XeTeX to do coloring without breaking text input stream, so proper mark positioning and shaping will be broken. There are some hacks that can produce some readable but very suboptimal text, involving use of ZWJ and/or Arabic tatweel. – Khaled Hosny Jun 20 '13 at 0:14
  • @KhaledHosny I already created a macro that can color the last letter of a word. But it uses the wrong form of the letter.(Please check the elaborated version of my question) If this isn't possible at all in XeTeX, even with a hack, then could you suggest another TeX distribution where it is possible? I found the following posts where you suggested a solution: tex.stackexchange.com/questions/13069/… tex.stackexchange.com/questions/84002/… – arabicstudent Jun 21 '13 at 19:03
  • Sorry I forgot this, coloring RTL text is broken in XeTeX (and e-TeX in general), you might have better luck using font colors instead (check fontspec manual). LuaTeX should have better support for this, the first question has ConTeXt answers, but the first can be easily adapted to LaTeX when using luacolor package. – Khaled Hosny Jun 22 '13 at 1:03
  • Actually, there is a LaTeX answer already in the second part of tex.stackexchange.com/a/13792/729 – Khaled Hosny Jun 22 '13 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.