10

I would like to highlight some texts. For Latin texts the \hl command of the soul package works well, but not for Arabic texts.

(\hl{SOME ARABIC TEXT} has only a small line as output in the pdf file.)

I could use \colorbox{yellow}{ARABIC TEXT} but it doesn't allow line breaks.

(The command \uline of the ulem package works for Arabic text too, so maybe it is not so difficult to get an "Arabic" \hl?)

(Perhaps the code of Leo Liu could be helpful: It makes some yellow boxes which cover the Arabic texts.)

I'm using xelatex (TeX Live 2012). Here is a minimal example:

\documentclass{article}
\usepackage{xcolor} 
\usepackage{ulem,soul}
%\usepackage{fontspec,color,xcolor,hyperref,xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\setotherlanguages{german}
\newfontfamily\arabicfont[Script=Arabic]{Times New Roman}

\begin{document}

\begin{german}
Highlighting works for \hl{latin texts}.
\end{german}

\hl{عربي} % you will just see a vertical small yellow line

\end{document}

EDIT: With this code:

\documentclass{article}
\usepackage{xcolor} 
\usepackage[normalem]{ulem}
%\usepackage{fontspec,color,xcolor,hyperref,xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\setotherlanguages{german}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Times New Roman}
\newcommand\hl{\bgroup\markoverwith % 
  {\textcolor{yellow}{\rule[-.5ex]{2pt}{2.5ex}}}\ULon}


\begin{document}
\begin{german}
Test \hl{for highlighting} text. %correct
\end{german}
\hl{عربي} % correct

\hl{عربي} % result: yellow box covers the word
\end{document}

I get the result:

arabicTest

So, in the first line the highlighting of the arabic text is correct - does someone know how to modify the code to make the hightlighting correct in the second line too?

3
  • 2
    It is very unlikely that you can do this due to \special bug/problems of TeX--XeT in RTL mode.
    – user22486
    Dec 9, 2012 at 13:48
  • I thought it is possible to get a highlighting function that works with arabic texts as the the underline function \uline of ulem. (BTW: Thanks for xecolour.)
    – steffan
    Dec 10, 2012 at 7:09
  • 1
    @VafaKhalighi Could you make that comment into an answer?
    – Joseph Wright
    Aug 4, 2013 at 19:02

1 Answer 1

2

As mentioned in comments:

It is very unlikely that you can do this due to \special bug/problems of TeX--XeT in RTL mode.

The way that specials are handled by the TeX--XeT model (currently) used by XeTeX means this can't really be done.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .