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?

  • 2
    It is very unlikely that you can do this due to \special bug/problems of TeX--XeT in RTL mode. – user22486 Dec 9 '12 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 '12 at 7:09
  • 1
    @VafaKhalighi Could you make that comment into an answer? – Joseph Wright Aug 4 '13 at 19:02
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.

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.