latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
123 stars 34 forks source link

babel is not aware of \if@nonlatin conditional from bidi #256

Closed Udi-Fogiel closed 10 months ago

Udi-Fogiel commented 10 months ago

bidi use a separate conditional from \if@RTL called \if@nonlatin in several places in its code, this conditional is not set by \RL, \setRL etc., so babel need to set this conditional according to the script (see section 4.4 of bidi's manual).

The places I'm aware it is used are in equation tags (in amsmath and mathtools) to correct the parenthesis, see [1] and [2], in breqn (not sure for what), in \text from amsmath to correct the direction of the text, see [3], and in a code it inserts between numbers and dots and dashes via \XeTeXinterchartoks, see [4], which I guess suppose to correct the order in arabic, but is wrong for hebrew and other languages (so it should be disabled sometimes).

Here is a code to demonstrate the problem with \text and tagged equations

\documentclass{article}

\usepackage{amsmath}
\usepackage[hebrew,provide=*,bidi=bidi-r]{babel}
\babelfont{rm}{David CLM}

\begin{document}
%\makeatletter\@nonlatintrue
\begin{equation}
1+2=3
\end{equation}

$\text{שלום עולם!}$
\end{document}

And this is a code to demonstrate the problem with the code that bidi inserts via \XeTeXinterchartoks

\documentclass{article}

\usepackage[hebrew,provide=*,bidi=bidi-r]{babel}
\babelfont{rm}{David CLM}

\begin{document}
\makeatletter\@nonlatintrue
1-2
\end{document}
jbezos commented 10 months ago

Interestingly, \setlatin and \setnonlatin are not documented (but they are defined). Certainly bidi is about ‘Arabic bidi’ and I’m not sure the order must be fixed in babel or in bidi. I'm thinking about it.

Udi-Fogiel commented 10 months ago

I’m not sure the order must be fixed in babel or in bidi. I'm thinking about it.

It always looked odd to me that bidi do that, isn't the script of the font should handle that by Itself?

FWIW, this is what polyglossia do (for several languages).