不失去连接的情况下着色阿拉伯后缀

不失去连接的情况下着色阿拉伯后缀

我怎样才能改变阿拉伯语单词结尾的颜色而不失去联系?这很丑陋,而且失去了可读性。我使用的是 Tex Live 2012:arabxetexxelatex欢迎使用任何软件包和/或引擎。

\documentclass{article}

\usepackage{arabxetex}

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


\begin{document}

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

\textarab[voc]{kitabhA}

\end{document}

答案1

一种解决方法是在文本分隔区域周围插入零宽度连接符,这将强制使用最终/初始形式。对于大多数字体来说,这应该是可以的,尽管这会破坏更高级字体中的上下文替代,但文本仍然应该可读。除此之外,在 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}

示例输出

PS 只使用常规颜色包,\addfontfeature{}每次调用时加载(并切换到)一种新字体,这对于仅切换颜色来说有点小题大做。

答案2

为了获得阿拉伯文字中的彩色元音,我们可以使用 ArabTeX 和acolor.sty。以下示例显示了如何使用它:

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

答案3

使用 ArabTeX 的内置机制,您可以通过连字符(不可见)指示给定字母应该将自己视为中间字母,尽管它位于单词边界。

kitabu-\textcolor{red}{-hA}

应该可以满足您的示例。但是字体的选择可能会显著改变结果。(我不知道 ha 的两种形式是否适合问题的上下文。)另请参阅我的答案在这里

答案4

acolor.sty您可以在互联网上找到该包,也可以复制并粘贴以下文件并将其放在您的或项目文件夹arabtex中的包中:texmf

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% acolor.sty
% ArabTeX macros for coloring the graphemes
% 06.11.2001
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Karel Mokry
%     student of Mathematics
%     Charles University in Prague
%     [email protected]
%     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

相关内容