[XeTeX] Images in LTR text

musa furber musaf at runbox.com
Mon Nov 7 22:28:56 CET 2005


On Nov 7, 2005, at 8:21 PM, Jonathan Kew wrote:

> On 7 Nov 2005, at 10:46 am, musa furber wrote:
>
>> On Nov 5, 2005, at 3:49 PM, Jonathan Kew wrote:
>>
>>> [...]
>>> You should be able to avoid the issue by surrounding the image  
>>> with \beginL...\endL, so that XeTeX knows it is a left-to-right  
>>> segment.
>>> [...]
>>
>> Is there a way that I can check the current text's directionality?  
>> If so, this would save me keeping two sets of macros, one ending  
>> with 'e' (English) and the other with 'a' (Arabic).
>
> I can't think of an easy way to check this, offhand.

The closest thing I could find so far is from

<http://www.tug.org/pipermail/tex-k/2004-December/001147.html>

which could be used like this:

\TeXXeTstate=1
\newif\ifatrl
\def\rlateverypar{\if at rl{\setbox\z@\lastbox\beginR\usebox\z@}\fi}
\let\oateverypar=\everypar
\def\everypar#1{\oateverypar{\rlateverypar#1}}

\def\switchtoRL{\beginR\@rltrue}
\def\switchtoLR{\beginL\@rltrue}

For LaTeX, I suppose would I do is write my own wrappers for \beginL  
and \beginR that include setting my direction flag.

> But I'm not sure you need to know, anyhow. When I tried embedding  
> an image with \XeTeXpicfile within RTL text, it worked fine if I  
> marked the image as an LTR run using \beginL ... \endL. And if the  
> surrounding text were left-to-right, this should be harmless. In  
> other words, I think you can safely include these direction tags in  
> your image macro, and use them within either LTR or RTL contexts.

The immediate use that comes to mind is getting rid of \mfsaaws{} and  
\mfsaawsa{} which insert the ligature for prayers up the Prophet in  
English and Arabic text, respectively. I was thinking of inserting  
the actual glyph, declaring the glyph and active char, and then in  
that char's macro I could check whether I am in a RTL context (in  
which case I make sure I am using a font that includes the character)  
or LTR (in which case I insert a picture of the glyph so I don't mess  
up the line spacing).

Those last two words give the major rationale for not simply  
switching fonts in both contexts. I am trying to avoid Arabic within  
English as much as possible because I always end up with nasty gaps  
between lines.

Maybe it's just a LaTeX problem and it's time to switch away.

Regards,
Musa



More information about the XeTeX mailing list