[luatex] Direction of hbox inside math

Khaled Hosny khaledhosny at eglug.org
Tue Apr 13 09:46:08 CEST 2010


On Tue, Apr 13, 2010 at 10:30:59AM +1000, Vafa Khalighi wrote:
> 
> 
> On Tue, Apr 13, 2010 at 4:02 AM, Khaled Hosny <khaledhosny at eglug.org> wrote:
> 
> 
>     Currently, hbox inside math inherits math not text direction, so in this
>     example:
> 
>     \textdir TRT text $\hbox{math}$
>     \bye
> 
>     The "math" word will be set left-to-right. At first glance this looks
>     natural, but with more thought I think it should instead follow the text
>     direction. In Iran and Morocco, math is set from left-to-right but with
>     Arabic text (sin, cos, "if else" etc.) so it would be simpler if text
>     set inside hboxes followed the text not math direction. The other issue,
>     which what actually inclined me to think about this, is that many tex
>     code abuses math mode to typeset text, most notably latex's tabular
>     environment, as a result one either needs to always set mathdir the same
>     as textdir (which is not an option for many) or go through hoops
>     redefining many internal macros of latex kernel and many other "frozen"
>     packages, to get things work.
> 
>     What do you think?
> 
> 
> 
> I think luatex behaviour in this matter is right and the direction inside math
> is better not to follow the text direction in the engine level.

For what reason? You don't give any.

> If you need to
> typeset an hbox RTL in math mode, you can simply have $\hbox dir TRT{math}$. I
> think  a macro package can provide all of this ideas, it can implement \hboxR
> and \hboxL like what I have done in the recent version of  bidi package.

That is all nice, and what I'm proposing doesn't prevent any one from
writing such macros.

> If one
> is doing math RTL, then would not mathdir TRT, already make that \hbox inside
> math mode RTL?

If one is doing right-to-left math then he is either doing right-to-left
text already, or can set textdir to TRT inside a group around math. The
difference it that any code dealing with right-to-left math is new code
and can be easily adapted, unlike things like LaTeX kernel.

> with latex's tabular thing, I guess you are right but we could
> redefine hbox to be always RTL inside tabular by some macro programming and one
> tabular environment is finished, hbox gets back its original definition.

That is kind of dirty hacks I'm trying to avoid. Patching +8 LaTeX
tabular implantation is not fun.


> However, I think this is not clean, I believe a clean way for latex's tabular
> is to have a primitive \halignR, such that it makes tabular RTL, if Taco wants,
> I even can send a source code where he can actually extract the implementation
> of \halignR from the source code.

ConTeXt can do tables with no resorting to math mode and it works very
well for Arabic, so it is a matter of stupid LaTeX choice than lack of
proper primitives.

Regards,
 Khaled

-- 
 Khaled Hosny
 Arabic localiser and member of Arabeyes.org team
 Free font developer


More information about the luatex mailing list