latex3 / tagging-project

Issues related to the tagging project
https://latex3.github.io/tagging-project/
LaTeX Project Public License v1.3c
37 stars 15 forks source link

lualatex-dev with tagging produces errors #734

Open John02139 opened 12 hours ago

John02139 commented 12 hours ago

I just updated to the new lualatex-dev, and a working code then showed some problems.

\DocumentMetadata 
{
    testphase={phase-III,math},
    pdfstandard = a-4,
    pdfversion  = 2.0,
    lang        = en-US,
}
\documentclass[11pt]{article}

\usepackage{mathtools}

\begin{document}

%% issue #1 - misaligned \Bigg\vert when tagging is in effect
\begin{equation}
\int_{\Gamma^h_s}\frac{\partial}{\partial n_x}\int_{\Gamma^a_\xi} \mkern-3mu b(\xi) \frac{\partial E(x|\xi)}{\partial n_\xi} \,dl_\xi \,\Bigg\vert_{x\to s}dl_s = 0 
\end{equation}

%% issue #2 - multlined and tagging don't play together
\begin{align}
S^i & =  \int_{\Gamma^h_{\mkern-4mu s}} \frac{\partial \theta}{\partial n_s} \, dl_s \\
    &   
    \begin{multlined}
        =\int_{\Gamma^h_{\mkern-4mu s}} \frac{a(s)}{2}\, dl_s + \int_{\Gamma^h_{\mkern-4mu s}} \int_{\mathcal{C}_\xi}a(\xi) \frac{\partial E(\xi|s)}{\partial n_s} \, dl_\xi dl_s 
    \\ +\int_{\Gamma^h}\lim_{x\to s^-} \frac{\partial}{\partial n_x}\int_{\Gamma^a} \mkern-3mu b(\xi) \frac{\partial E(x|\xi)}{\partial n_\xi} \,dl_\xi dl_s 
    \end{multlined}
\end{align}

\end{document}

When math tagging is active, \Bigg\vert is vertically misaligned (does not affect \vert by itself).

Screenshot 2024-10-15 at 4 36 25 PM

In addition, I get the following errors from the second equation (seem to be related to multlined / mathtools):

...e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:89: assertion failed!
stack traceback:
    [C]: in function 'assert'
    ...e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:89: in function <.
..e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:81>.
\endaligned ...amml_amsmath_finalize_inner_table: 

l.25 \end{align}

? 
...e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:89: assertion failed!
stack traceback:
    [C]: in function 'assert'
    ...e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:89: in function <.
..e/2024/texmf-dist/tex/lualatex/luamml/luamml-amsmath.lua:81>.
\endaligned ...amml_amsmath_finalize_inner_table: 

l.25 \end{align}

Neither problem appears without math tagging or with current versions of lualatex, pdftex, or pdftex-dev.

(I'm not sure whether these are symptoms of the same problem or two separate problems.)

John02139 commented 11 hours ago

Note - The first error disappears if I load unicode-math with lualatex-dev, but the second does not. However, neither problem exists unless I run the lualatex-dev version (with or without unicode-math).

u-fischer commented 10 hours ago

well @zauguin will have to confirm, but I think the mathtools environment needs this patch (but the resulting mathml is imho not correct yet).

\DocumentMetadata 
{
    testphase={phase-III,math},
    pdfstandard = a-4,
    pdfversion  = 2.0,
    lang        = en-US,
}
\documentclass[11pt]{article}

\usepackage{mathtools}
\ExplSyntaxOn\makeatletter
\renewcommand*\MT_mult_internal:n [1]{
 \MH_if_boolean:nF {outer_mult}{\alignedspace@left} %<-- requires amsmath 2016/11/05
  \MT_next:
  \bgroup
    \Let@
    \def\l_MT_multline_lastline_fint{0 }
    \chardef\dspbrk@context\@ne \restore@math@cr
    \MH_let:NwN \math@cr@@\MT_mult_mathcr_atat:w
    \MH_let:NwN \shoveleft\MT_shoveleft:wn
    \MH_let:NwN \shoveright\MT_shoveright:wn
    \spread@equation
    \MH_set_boolean_F:n {mult_firstline}
    \MT_measure_mult:n {#1}
    \MH_if_dim:w \l_MT_multwidth_dim<\l_MT_multline_measure_fdim
      \MH_setlength:dn \l_MT_multwidth_dim{\l_MT_multline_measure_fdim}
    \fi
    \MH_set_boolean_T:n {mult_firstline}
    \MH_if_num:w \l_MT_multline_lastline_fint=\@ne
      \MH_let:NwN \math@cr@@ \MT_mult_firstandlast_mathcr:w
    \MH_fi:
    \ialign\bgroup
      \hfil\strut@$\m@th\displaystyle{}##
      \luamml_flag_save:nNn {} \displaystyle {mtd}
      $
      \__luamml_amsmath_add_last_to_row:
      \hfil
      \crcr
      \hfilneg
      #1
}
\ExplSyntaxOff\makeatother
\usepackage{unicode-math}

\begin{document}

%% issue #1 - misaligned \Bigg\vert when tagging is in effect
\begin{equation}
\int_{\Gamma^h_s}\frac{\partial}{\partial n_x}\int_{\Gamma^a_\xi} \mkern-3mu b(\xi) \frac{\partial E(x|\xi)}{\partial n_\xi} \,dl_\xi \,\Bigg\vert_{x\to s}dl_s = 0 
\end{equation}

%% issue #2 - multlined and tagging don't play together
\begin{align}
S^i & =  \int_{\Gamma^h_{\mkern-4mu s}} \frac{\partial \theta}{\partial n_s} \, dl_s \\
    &   
    \begin{multlined}
        =\int_{\Gamma^h_{\mkern-4mu s}} \frac{a(s)}{2}\, dl_s + \int_{\Gamma^h_{\mkern-4mu s}} \int_{\mathcal{C}_\xi}a(\xi) \frac{\partial E(\xi|s)}{\partial n_s} \, dl_\xi dl_s 
    \\ +\int_{\Gamma^h}\lim_{x\to s^-} \frac{\partial}{\partial n_x}\int_{\Gamma^a} \mkern-3mu b(\xi) \frac{\partial E(x|\xi)}{\partial n_\xi} \,dl_\xi dl_s 
    \end{multlined}
\end{align}

\end{document}