[latex3-commits] [git/LaTeX3-latex3-latex2e] master: Fixes for math - ensure the \mathdir within math and within tables (80a071d)

GitHub noreply at github.com
Tue Mar 26 18:03:02 CET 2019


Repository : https://github.com/latex3/latex2e
On branch  : master
Link       : https://github.com/latex3/latex2e/commit/80a071d137ea74d60b4881800e6e5c434f2d8caf

>---------------------------------------------------------------

commit 80a071d137ea74d60b4881800e6e5c434f2d8caf
Author: Javier Bezos <jbezos at users.noreply.github.com>
Date:   Tue Mar 26 18:03:02 2019 +0100

    Fixes for math - ensure the \mathdir within math and within tables


>---------------------------------------------------------------

80a071d137ea74d60b4881800e6e5c434f2d8caf
 required/babel/babel.dtx |   40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/required/babel/babel.dtx b/required/babel/babel.dtx
index 1497432..ab551fe 100644
--- a/required/babel/babel.dtx
+++ b/required/babel/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2019/03/19 v3.27.1585 The Babel package]
+\ProvidesFile{babel.dtx}[2019/03/26 v3.27.1592 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -2495,7 +2495,7 @@ _\babelprovide[import, main]{arabic}_
 
 \New{3.16} \textit{To be expanded}. Selects which layout elements are
 adapted in bidi documents, including some text elements. You may use
-several options with a comma-separated list (eg,
+several options with a dot-separated list (eg,
 |layout=counters.contents.sectioning|). This list will be expanded in
 future releases (tables, captions, etc.). Note not all options are
 required by all engines.
@@ -3917,8 +3917,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.27.1585>>
-%<<date=2019/03/19>>
+%<<version=3.27.1592>>
+%<<date=2019/03/26>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -9263,6 +9263,7 @@ help from Bernd Raichle, for which I am grateful.
 \ifodd\bbl at engine  % luatex=1
   \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
   \DisableBabelHook{babel-bidi}
+  \chardef\bbl at thetextdir\z@
   \chardef\bbl at thepardir\z@
   \def\bbl at getluadir#1{%
     \directlua{
@@ -9283,12 +9284,23 @@ help from Bernd Raichle, for which I am grateful.
     \fi}
   \def\bbl at textdir#1{%
     \bbl at setluadir{text}\textdir{#1}% TODO - ?\linedir
+    \chardef\bbl at thetextdir#1\relax
     \setattribute\bbl at attr@dir{\numexpr\bbl at thepardir*3+#1}}
-  \def\bbl at pardir#1{\bbl at setluadir{par}\pardir{#1}%
+  \def\bbl at pardir#1{%
+    \bbl at setluadir{par}\pardir{#1}%
     \chardef\bbl at thepardir#1\relax}
   \def\bbl at bodydir{\bbl at setluadir{body}\bodydir}
   \def\bbl at pagedir{\bbl at setluadir{page}\pagedir}
   \def\bbl at dirparastext{\pardir\the\textdir\relax}%   %%%%
+  % Sadly, we have to deal with boxes in math with basic:
+  \def\bbl at mathboxdir{%
+    \ifcase\bbl at thetextdir\relax
+      \everyhbox{\bgroup\aftergroup\egroup\textdir TLT\relax}%
+    \else
+      \everyhbox{\bgroup\aftergroup\egroup\textdir TRT\relax}%
+    \fi}
+  \everymath{\bbl at mathboxdir}
+  \everydisplay{\bbl at mathboxdir}
 \else % pdftex=0, xetex=2
   \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
   \DisableBabelHook{babel-bidi}
@@ -11813,9 +11825,9 @@ help from Bernd Raichle, for which I am grateful.
 \fi
 \ifx\bbl at opt@layout\@nnil\endinput\fi  % if no layout
 \ifx\bbl at beforeforeign\leavevmode % A poor test for bidi=
-  \def\bbl at nextfake#1{%
-    \mathdir\bodydir  % non-local, use always inside a group!
+  \def\bbl at nextfake#1{%  non-local changes - always inside a group!
     \bbl at exp{%
+      \mathdir\the\bodydir  
       #1%              Once entered in math, set boxes to restore values
       \everyvbox{%
         \the\everyvbox
@@ -18397,8 +18409,11 @@ local function insert_numeric(head, state)
   return head, new_state
 end
 
--- \hbox with an explicit dir can lead to wrong results
--- <R \hbox dir TLT{<R>}> and <L \hbox dir TRT{<L>}>
+-- TODO - \hbox with an explicit dir can lead to wrong results
+-- <R \hbox dir TLT{<R>}> and <L \hbox dir TRT{<L>}>. A small attempt
+-- is made to improve the situation, but the problem is the 3-dir
+-- model in babel/Unicode and the 2-dir model in LuaTeX don't fit
+-- well.
 
 function Babel.bidi(head, ispar, hdir)
   local d   -- d is used mainly for computations in a loop
@@ -18426,9 +18441,14 @@ function Babel.bidi(head, ispar, hdir)
                  (temp == 2 and 'al')
   elseif ispar then            -- Or error? Shouldn't happen
     save_outer = ('TRT' == tex.pardir) and 'r' or 'l'
-  else
+  else                         -- Or error? Shouldn't happen
     save_outer = ('TRT' == hdir) and 'r' or 'l'
   end
+    -- when the callback is called, we are just _after_ the box,
+    -- and the textdir is that of the surrounding text
+  -- if not ispar and hdir ~= tex.textdir then 
+  --   save_outer = ('TRT' == hdir) and 'r' or 'l'
+  -- end
   local outer = save_outer
   local last = outer
   -- 'al' is only taken into account in the first, current loop





More information about the latex3-commits mailing list