0

I would like to get Colour Coded Al-Quran text with Tajweed Rules. I can write Arabic text with latex but they are not color coded. How do I get color coded text?

MWE:

\documentclass{book}

\usepackage{setspace}

\usepackage{fontspec} \usepackage{polyglossia,quran}

\setmainlanguage{english} \setotherlanguage{arabic}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Scheherazade}

\begin{document}

\begin{Arabic} \lineskiplimit=-1000pt \setstretch{1.2} \quransurah[114] \end{Arabic}

\end{document}

Output:
enter image description here

I would like to get as below :

enter image description here

MKS
  • 412

1 Answers1

1

Here an option with lualatex engine and babel package (you need a recent distribution)

\documentclass{article}
\usepackage[bidi=basic]{babel}
\babelprovide[import=ar,main]{arabic}
\babelfont{rm}{Amiri}

\usepackage{luacode} \usepackage{luacolor}

\newcommand\colr[2]{% \protect\leavevmode \begingroup \color{#1}% #2% \endgroup }

\begin{luacode} function colored ( s ) s = unicode.utf8.gsub(s, "[ًٌٍَُِْ]","\colr{red}{%1}") return s end \end{luacode}

\def\FormatOn{% \directlua{luatexbase.add_to_callback("process_input_buffer", colored, "colored")}} \def\FormatOff{% \directlua{luatexbase.remove_from_callback("process_input_buffer","colored")}}

\pagestyle{empty}

\begin{document}

\centering\Huge

\FormatOn

تَجرِيبْ بسمِ اللهِ الرحمَانِ الرَحِيمْ

\FormatOff

\begin{luacode} function colored ( s ) s = unicode.utf8.gsub(s, "[بم]","\colr{blue}{%1}") return s end \end{luacode}

\FormatOn

تَجرِيبْ بسمِ اللهِ الرحمَانِ الرَحِيمْ

\FormatOff

تَجرِيبْ بسمِ اللهِ الرحمَانِ الرَحِيمْ

\end{document}

enter image description here

Salim Bou
  • 17,021
  • 2
  • 31
  • 76