15

is it possible to do this with XelaTex? (Im using texmaker):

enter image description here

I already tried some of the suggestions posted here, for instance by using Arabtex. But I wanted to this with arabic type text and not transliterating everything. If not what program is out there that can produce this?

Thanks in advance!

  • 1
    Related: Coloring combining characters without changing color of a base character This is a hard problem that I don't think anyone has solved adequately. – Alan Munn Nov 22 '13 at 14:50
  • 1
    I don't know if this helps you, but at pragma-ade.com/general/manuals/mk.pdf, you'll find a document about ConTeXt mkiv, i.e., with the luatex engine. Chapter XIII of this document contains several examples of colored arabic text. Since I don't know anything about arabic myself, this may or not be of interest to you. – Thomas Feb 11 '15 at 4:42
  • This seems a duplicate of tex.stackexchange.com/questions/84002/… at least for the suffix part – David Carlisle Feb 11 '15 at 12:29
  • Yes, it is partly a duplicate. I agree. – chejnik Feb 11 '15 at 12:40
  • @chejnik It would help for those of us who might be able to do the tex but can't read or write the script if a small sample document was added (by you or the OP) with some indication of which are the vowels – David Carlisle Feb 11 '15 at 13:35
2

I give it a try, although the answer may not yet be complete/final.

The reference to ConTeXt mentioned by @Alan Munn contains a solution to the question of diacritical marks (vowels), including the use of unicode characters instead of translitteration. But it uses general rules to colour all glyphs of a given type in the same way, not individual ones in a word.

I restrict to the use of XeLaTeX and the problem of colouring of endings (or any part of words) with and without translitteration. Since the design of ArabTeX more than 20 years ago, there exists the possibility to "fake" initial/medial/final positions for arabic letters by means of a hyphen. This continues to work also for unicode glyphs.

\documentclass{minimal} \usepackage{xcolor} \usepackage{arabxetex} 
\newfontfamily\arabicfont[Script=Arabic, Scale=1.5]{Scheherazade}
\begin{document}

\def\rshift#1.{\vskip1cm\rightline{\textbf{#1}\hskip4cm}}
\def\r{\color{red}} \def\b{\color{blue}}
\def\kerningmsg{\textLR{\textit{\color{black}with kerning!}\ }}

\rshift Vocalised.
\begin{arab}[voc]\b
mu`allimu-{\r wna} ka_tiru{\r wna}

ma`a mu`allimi-{\r yna} ka_tiri{\r -yna}

ma`a mu`allimi-\kern-1pt{\r yna} ka_tiri{\r -yna} \kerningmsg
\end{arab}

\rshift No vocalisation.
\begin{arab}[novoc]\b
mu`allimu-{\r wna} ka_tiru{\r wna}

ma`a mu`allimi-{\r yna} ka_tiri{\r yna}
\end{arab}

\rshift Vocalised from unicode.
\begin{arab}[voc]\b
مُعَلِّمُ-{\r-ونَ} كَثئر-{\r\-ون} 
\end{arab}

\rshift Vocalisation removed from unicode.
\begin{arab}[novoc]\b
مُعَلِّمُ-{\r-ونَ} كَثئر-{\r ون}
\end{arab}

\end{document}

Save this in arabcolour.tex. Make sure you have a recent distribution of TeXlive or the necessary XeTeX, xcolor and arabxetex packages installed.

The result, generated with xelatex arabcolour, looks very similar to the model given in the original question. But read on below!

Screenshot from PDF file

A well trained eye will see that the ya in the second line has been separated too much from the begin of the word. "kerning" helps here, and you probably have to try on an individual word-by-word basis what is best to glue the words together again. It may vary with different fonts, who give less usefull results (see the ha variant in Amiri font from here - The joining of the waw becomes impossible with this font.).

example given in other answer

Personally I find the transliteration input more readable. Although I tried to define shortcuts for the colour change, the left-right/right-left changes make the "WYSIWYG" an irony and may depend on editors and even on the exact position of a linebreak. The source does not look the same as here in gedit for example, even if copy+paste should preserve the contents logically, and you can try. Hint: When constructing your own words, first type the full sentences, then insert the {\r…} parts for highlighting in one go.

I believe that this is the maximum you will get with XeLaTeX however. So the complete answer is likely to be a combination of ConTeXt mentioned above and this one, be it with transliteration or not.

  • This answer doesn't seem to work for coloring non-suffix diacritics independent of their base character. – hftf Apr 17 '15 at 1:00
  • 1
    @hftf, isn't that what I wrote (par. 2 and 3)? – Dirk Apr 17 '15 at 6:41

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.