17

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}
17

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}

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.

3

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.

2

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

\documentclass[a4paper,12pt]{report}
\usepackage[utf8,latin1]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx}
\usepackage{arabtex}
\usepackage{acolor}
\usepackage{fancybox}
\usepackage{pgf,tikz}
\usepackage[left=1.5cm,right=1.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\definecolor{lightyellow}{rgb}{1,1,.933777}
\definecolor{darkgreen}{rgb}{0.2,0.6,0.2}
\definecolor{poppyred}{rgb}{0.89,0.08,0.3}
\definecolor{poppyredd}{rgb}{0.78,0.0,0.09}
\definecolor{poppyreddd}{rgb}{0.63,0.0,0.0}
\pagestyle{empty}
\begin{document}

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

\setlength{\fboxrule}{3pt}
\setlength{\fboxsep}{4pt}

\begin{center}
\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 $}}}
\end{center}

\bigskip

\begin{center}
\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$ }}}

\end{center}
\end{document}
1

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
%     jazyk@artax.karlin.mff.cuni.cz
%     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
%

\NeedsTeXFormat{LaTeX2e}

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

\RequirePackage{xcolor}
\RequirePackage{ifthen}


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

\gdef\acoloron{\def\a@color##1##2{\textcolor{acolor4##1}{##2}}}

\gdef\noacolor{\def\a@color##1##2{##2}}


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

\gdef\acolorlet#1#2{\acolor{#1}{acolor4#2}}

\gdef\acolor#1#2{%
    \ifthenelse{\equal{#1}{everything}}{\acolor{letters}   {#2}%
                                        \acolor{omissibles}{#2}}{%
    \ifthenelse{\equal{#1}{letters}}{\acolor{isolated}{#2}%
                                     \acolor{initial} {#2}%
                                     \acolor{medial}  {#2}%
                                     \acolor{final}   {#2}}{%
    \ifthenelse{\equal{#1}{omissibles}}{\acolor{diacritics}{#2}%
                                        \acolor{hamzamadda}{#2}}{%
    \ifthenelse{\equal{#1}{diacritics}}{\acolor{vowelmarks}{#2}%
                                        \acolor{emptymarks}{#2}%
                                        \acolor{shadda}    {#2}}{%
    \ifthenelse{\equal{#1}{vowelmarks}}{\acolor{fatha}   {#2}%
                                        \acolor{kasra}   {#2}%
                                        \acolor{damma}   {#2}%
                                        \acolor{quran}   {#2}%
                                        \acolor{ammad}   {#2}%
                                        \acolor{zwarakay}{#2}%
                                        \acolor{bars}    {#2}}{%
    \ifthenelse{\equal{#1}{emptymarks}}{\acolor{sukun}{#2}%
                                        \acolor{wasla}{#2}}{%
    \ifthenelse{\equal{#1}{hamzamadda}}{\acolor{hamza}{#2}%
                                        \acolor{madda}{#2}}{%
    \colorlet{acolor4#1}{#2}}}}}}}}\ignorespaces}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 }}


%\def\a@create#1{\AtBeginDocument{\acolor{#1}{.}}}

%\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}

%\a@create{isolated}\a@create{initial}\a@create{medial}\a@create{final}


\AtBeginDocument{\acoloron\acolor{everything}{.}}

\endinput

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.