[XeTeX] Problems with hyperref and bidi

Jonathan Kew jonathan_kew at sil.org
Sat Apr 26 23:35:42 CEST 2008


On 26 Apr 2008, at 8:58 pm, Khaled Hosny wrote:

> On Sat, Apr 26, 2008 at 11:19:24AM +1000, Ross Moore wrote:
>> Hi Vafa, Khaled, and others.
>>
>>
>> On 26/04/2008, at 12:42 AM, VAFA KHALIGHI wrote:
>>> If you are producing a book or a report, then put these commands in
>>> your preamble: (You can vary the hyperref options to meet your
>>> needs or add anyother things)
>>
>>> %%%%%%%%%%%%%%%%%%
>>>
>>> If you are producing an article, then put these commands in your
>>> preamble:
>>
>>
>>> \makeatletter
>>> \renewcommand*\l at section[2]{%
>>> \ifnum \c at tocdepth >\m at ne
>>> \addpenalty{-\@highpenalty}%
>>> \vskip 1.0em \@plus\p@
>>> \setlength\@tempdima{1.5em}%
>>> \begingroup
>>> \parindent \z@ \rightskip \@pnumwidth
>>> \parfillskip -\@pnumwidth
>>> \leavevmode \bfseries
>>> \advance\leftskip\@tempdima
>>> \hskip -\leftskip
>>> #1\nobreak\hfil \nobreak\hb at xt@\@pnumwidth{\hss \textroman{#2}}\par
>>
>> This is using the \textroman  command from  arabxetex.sty .
>>
>>> \penalty\@highpenalty
>>> \endgroup
>>> \fi}
>>> \makeatother
>>> %%%%%%%%%%%%%%%%%%%%%%%%%%
>>
>> If you don't use arabxetex.sty , or even if you do, then
>> also include a coding line here:
>>
>>     \providecommand{\textroman}[1]{{\LR{\rmfamily #1}}}
>>
>> which will give you this command if your packages don't
>> define it already.
>>
>>
>> But even with this, there are still some 'minor' problems.
>>
>> Using  xdvipdfmx  as the xdv processor, I get warnings:
>>
>> rossmoor% xdvipdfmx-0997 test.xdv
>> test.xdv -> test.pdf
>> [1
>>
>> ** WARNING ** End color with no corresponding begin color.]
>>
>> ** WARNING ** Invalid CMap mapping entry. (ignored)
>>
>>
>> Using  xdv2pdf  (MacOS X only)  the messages are:
>>
>>    *** rule color stack underflow
>>
>>    *** text color stack underflow
>>
>>
>> Clearly there is an interaction with the color-stack mechanism
>> that isn't yet adapted to getting the order of the push/pop
>> correct within a  right-to-left setting.
>>
>> To resolve this, it looks like the \LR cannot apply to just
>> the text of the hyperlink, but must also include the internal
>> color-commands that are placed by hyperref .
>> But this cannot be done globally, as there may be a legitimate
>> need for \RL text within the text of the anchor.
>>
>> Surely someone has tackled this kind of difficulty already.
>>
>
> Reading the bidi package documentation again
> (http://www.ctan.org/tex-archive/macros/xetex/latex/bidi/bidi.pdf)
> It is mentioned that the color commands doesn't work properly with RL,
> though the package redefine \textcolor command, it doesn't work with
> hyperref. This thread is related too
> http://listserv.tau.ac.il/cgi-bin/wa? 
> A2=ind0404&L=ivritex&D=0&T=0&P=268,
> though non of the mentioned workarounds seem to affect hyperref.


I think all this is related to the basic problem that when the TeX-- 
XeT bidi mechanism is used, horizontal lists get reversed before  
output. This means that when you have \special commands in the line,  
their order also gets reversed. So if the text contains a \special  
that in some way implements "begin a link" or "set a new color", and  
later in the same line there's "end link" or "pop the color stack",  
the DVI driver ends up seeing these in the opposite order.

I submitted the original message in this thread to the XeTeX bug  
tracker at <http://sourceforge.net/tracker/? 
group_id=194926&atid=951385>, as I think it's an issue that can't  
easily be solved at the level of individual documents or macro  
packages. You may be able to work around some of the problems, but a  
general solution will need to be implemented at a more fundamental  
level.

JK



More information about the XeTeX mailing list