latex3 / tagging-project

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

Some math fonts show misaligned \Bigg\vert when math tagging is active #757

Open John02139 opened 4 days ago

John02139 commented 4 days ago
Screenshot 2024-11-08 at 9 08 05 AM
\DocumentMetadata 
{
    testphase={phase-III,math},
    pdfstandard = a-4f,
    pdfversion  = 2.0,
    lang        = en-US,
}
\documentclass[11pt]{article}

\usepackage{unicode-math}

\setmathfont{STIXTwoMath-Regular}[
    Extension = .otf,
    Scale=MatchUppercase,
]
%\setmathfont{texgyretermes-math}[
%       Extension = .otf,
%       Scale=MatchUppercase,
%]
%\setmathfont{texgyrepagella-math}[
%       Extension = .otf,
%       Scale=MatchUppercase,
%]
%\setmathfont{LucidaBrightMathOT}[%
%     Extension=.otf,
%     Scale=MatchUppercase,
%     BoldFont=LucidaBrightMathOT-Demi.otf,
%]
%\setmathfont{Asana-Math}[
%       Extension = .otf,
%       Scale=MatchUppercase,
%]
%\setmathfont{FiraMath-regular}[
%       Extension = .otf,
%       Scale=MatchUppercase,
%]
%\setmathfont{GFSNeohellenicMath}[
%       Extension = .otf,
%       Scale=MatchUppercase,
%]
%\setmathfont{libertinusmath-regular}[
%   Extension = .otf,   
%   Scale=MatchUppercase,
%   ]

\begin{document}
The \verb+\Bigg\vert+ is vertically misaligned when math tagging is active if certain math fonts are loaded.
\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}
This behavior occurs for Stix2, TeX Gyre fonts,  and Lucida; but NOT for FiraMath, GFSNeohellenicMath, Libertinus, or default LMR.   
\end{document}
u-fischer commented 4 days ago

luamml changes \bBigg@ to use a luatex primitive, so it looks as if that doesn't work properly for some fonts:

\documentclass[11pt]{article}
\usepackage{unicode-math}

\setmathfont{STIXTwoMath-Regular}[
    Extension = .otf,
    Scale=MatchUppercase,
]
\makeatletter
\ExplSyntaxOn
\cs_set:Npn \bBigg@ #1 #2 {
  {
    \ensuremath {
      \Uvextensible height~#1 \big@size axis~exact~#2
    }
  }
}
\makeatother
\ExplSyntaxOff
\begin{document}
The \verb+\Bigg\vert+ is vertically misaligned when math tagging is active if certain math fonts are loaded.
\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}
This behavior occurs for Stix2, TeX Gyre fonts,  and Lucida; but NOT for FiraMath, GFSNeohellenicMath, Libertinus, or default LMR.   
\end{document}

@davidcarlisle @zauguin thoughts?

davidcarlisle commented 4 days ago

@u-fischer the luatex manual isn't exactlyclear but if you force height and depth to be half the requested size rather than relying on axis to shift then it's closer to the intended layout

      \Uvextensible height~#1~ \dimexpr0.5\big@size\relax ~ depth ~#1~  \dimexpr0.5\big@size\relax~ axis~~#2
davidcarlisle commented 4 days ago

actually having got clarification in chat axis does not re-centre the entire delimiter on the axis, just interprets height and depth relative to that, so the code you originally showed should have a depth component as well (not clear why it appears to work in some cases without)

u-fischer commented 4 days ago

So you can try with definition which should go after \begin{document}

\makeatletter
\ExplSyntaxOn
\cs_set:Npn \bBigg@ #1 #2 {
  {
    \ensuremath {
      \Uvextensible height~#1~ \dimexpr0.5\big@size\relax ~ depth ~#1~  \dimexpr0.5\big@size\relax~ axis~exact~#2
    }
  }
}
\makeatother
\ExplSyntaxOff
John02139 commented 4 days ago

Thanks, that code works with all the fonts I tried.