-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
amsmath.dtx: LuaTeX version of \genfrac@rule and \genfrac@choice are buggy #432
Comments
Yes thanks, not sure how that slipped through. |
@davidcarlisle I had a theory why it slipped through: |
@davidcarlisle Another thing while I was digging: Why is the According to But \genfrac@rule{#2}{21}\textfont{1.01} % for XeTeX
\genfrac@rule{#2}\textstyle\textfont{1.01} % for LuaTeX |
A sample test file: \documentclass{article}
\usepackage{amsmath}
% One em quad in cmsy10 is 1.000003 of design size,
% i.e., 10pt cmsy10 has \fontdimen6=655361sp=10.00002pt.
% This hides the inappropriate
% \genfrac@rule{#2}{21}\textfont{1} for XeTeX, and
% \genfrac@rule{#2}\textstyle\textfont{1} for LuaTeX.
% To highlight these two hidden bugs, we load cmsy10
% slightly scaled down for this particular test.
\DeclareFontShape{OMS}{cmsy}{m}{n}{%
<5><6><7><8><9>gen*cmsy%
<10>*[0.99999]cmsy10% load cmsy10 slightly scaled down
<10.95><12><14.4><17.28><20.74><24.88>cmsy10%
}{}
\begin{document}
$\displaystyle \binom{n}{k},
\textstyle \binom{n}{k},
\scriptstyle \binom{n}{k},
\scriptscriptstyle\binom{n}{k}$
\ifx\directlua\undefined
\ifx\XeTeXcharclass\undefined
\else
\fontdimen20\textfont2=0pt \fontdimen21\textfont2=0pt %
\fontdimen20\scriptfont2=0pt \fontdimen21\scriptfont2=0pt %
\fontdimen20\scriptscriptfont2=0pt \fontdimen21\scriptscriptfont2=0pt %
\fi
\else
\Umathfractiondelsize\displaystyle=0pt %
\Umathfractiondelsize\textstyle=0pt %
\Umathfractiondelsize\scriptstyle=0pt %
\Umathfractiondelsize\scriptscriptstyle=0pt %
\fi
$\displaystyle \binom{n}{k},
\textstyle \binom{n}{k},
\scriptstyle \binom{n}{k},
\scriptscriptstyle\binom{n}{k}$
\end{document} |
@davidcarlisle Two additional fixes:
Now the test file below produces identical(*) results across 3 different engines. \documentclass{article}
\usepackage{amsmath}
% One em quad in cmsy10 is 1.000003 of design size,
% i.e., 10pt cmsy10 has \fontdimen6=655361sp=10.00002pt.
% This hides the inappropriate
% \genfrac@rule{#2}{21}\textfont{1} for XeTeX, and
% \genfrac@rule{#2}\textstyle\textfont{1} for LuaTeX.
% To highlight these two hidden bugs, we load cmsy10
% slightly scaled down for this particular test.
\DeclareFontShape{OMS}{cmsy}{m}{n}{%
<5><6><7><8><9>gen*cmsy%
<10>*[0.99999]cmsy10% load cmsy10 slightly scaled down
<10.95><12><14.4><17.28><20.74><24.88>cmsy10%
}{}
\makeatletter
\ifx\directlua\@undefined
\ifx\XeTeXcharclass\@undefined
\else
% XeTeX version
% \cs{genfrac@rule} takes 5 arguments: \arg{1} delimiter,
% \arg{2} mathstyle, \arg{3} fontdimen index, \arg{4} font,
% \arg{5} fontdimen value (taken to match cmsy10, cmsy7, cmsy5).
\def\genfrac@rule#1#2#3#4#5{%
\hbox{$#2% <--- mathstyle here to get the correct axis height
\left#1\vcenter{\hrule \@width\z@
\@height
\ifdim\fontdimen#3#4\tw@=\z@
#5\fontdimen6#4\tw@
\else
\fontdimen#3#4\tw@
\fi
}\right.$}}
\def\genfrac@choice#1#2{%
\ifx @#2@\else
\ifx c#1\kern-\nulldelimiterspace\fi
{\delimitershortfall\z@\delimiterfactor\@m
\mathsurround\z@\nulldelimiterspace\z@
\mathchoice
{\genfrac@rule{#2}\displaystyle{20}\textfont{2.39}}%
{\genfrac@rule{#2}\textstyle{21}\textfont{1.01}}%
{\genfrac@rule{#2}\scriptstyle{21}\scriptfont{0.988}}%
{\genfrac@rule{#2}\scriptscriptstyle{21}\scriptscriptfont{0.964}}%
}%
\ifx o#1\kern-\nulldelimiterspace\fi
\fi
}
\fi
\else
% LuaTeX version
\def\genfrac@rule#1#2#3#4{%
\hbox{$#2% <--- mathstyle here to get the correct axis height
\left#1\vcenter{\hrule \@width\z@
\@height
\ifdim\Umathfractiondelsize#2=\z@
#4\fontdimen6#3\tw@
\else
\Umathfractiondelsize#2%
\fi
}\right.$}}
\def\genfrac@choice#1#2{%
\ifx @#2@\else
\ifx c#1\kern-\nulldelimiterspace\fi
{\delimitershortfall\z@\delimiterfactor\@m
\mathsurround\z@\nulldelimiterspace\z@
\mathchoice
{\genfrac@rule{#2}\displaystyle\textfont{2.39}}%
{\genfrac@rule{#2}\textstyle\textfont{1.01}}%
{\genfrac@rule{#2}\scriptstyle\scriptfont{0.988}}%
{\genfrac@rule{#2}\scriptscriptstyle\scriptscriptfont{0.964}}%
}%
\ifx o#1\kern-\nulldelimiterspace\fi
\fi
}
\fi
\makeatother
\begin{document}
$\displaystyle \binom{n}{k},
\textstyle \binom{n}{k},
\scriptstyle \binom{n}{k},
\scriptscriptstyle\binom{n}{k}$
\ifx\directlua\undefined
\ifx\XeTeXcharclass\undefined
\else
\fontdimen20\textfont2=0pt \fontdimen21\textfont2=0pt %
\fontdimen20\scriptfont2=0pt \fontdimen21\scriptfont2=0pt %
\fontdimen20\scriptscriptfont2=0pt \fontdimen21\scriptscriptfont2=0pt %
\fi
\else
\Umathfractiondelsize\displaystyle=0pt %
\Umathfractiondelsize\textstyle=0pt %
\Umathfractiondelsize\scriptstyle=0pt %
\Umathfractiondelsize\scriptscriptstyle=0pt %
\fi
$\displaystyle \binom{n}{k},
\textstyle \binom{n}{k},
\scriptstyle \binom{n}{k},
\scriptscriptstyle\binom{n}{k}$
\end{document} |
@davidcarlisle tell me not if that assignment is premature :-) |
They come from different font, but the change in LuaTeX seems intentional. What happens is the following: In TeX, delimiters come in a small and a big variant. If the small variant (and all successor glyphs) is too small, TeX tries the small variant of bigger mathstyles. If all of them are too small, it finally tries the big version (and it's successors). (Again, this falls back to bigger mathstyles if it is too small, but since the last successor if often extensible this rarely happens) LuaTeX on the other hand never looks at other mathstyles. So effectivly, the parens in other engines are the small While this change does not seem to be documented, it is consistent with LuaTeX's general tendency not to use the small/big delimiter distinction so much. |
This issue has been automatically marked as stale because it has not had recent activity. |
This issue has been automatically marked as stale because it has not had recent activity. |
This issue has been automatically marked as stale because it has not had recent activity. |
This issue has been automatically marked as stale because it has not had recent activity. |
* add support for row headers * Declare variable * update testfiles (braces) * handle negative row header values * add testfiles * extend documentation * add multirow code * remove stray plug * guard variant, update testfiles * multirow testfile * handle missing fields for multirow * issue #432 * add changes, update date * update luatex testfiles * handle issue #444 * correct test, default structure * version update and changes entry for lttagging * provide sockets if they do not exist * start ltnews entry * corrections from review * s + commas
Brief outline of the bug
The traditional TFM-based math symbol fonts (family 2) are required to have
\fontdimen20
and\fontdimen21
when constructing generalized fractions with delimiters. These two font dimensions do not have correspondences in the OpenType Math Table. So, in order to support OpenType math fonts under XeLaTeX/LuaLaTeX,amsmath
provides different implementations for\genfrac
.However, there seems to be illogical code in the LuaTeX version.
Minimal example showing the bug, Log file (required) and possibly PDF file
Not applicable. The use of OpenType math fonts needs the
unicode-math
package, which is forbidden by\RequirePackage{latexbug}
. And it’s too much work to write\textfont1=<some OpenType math font> \textfont2=<some OpenType math font> \textfont3=<some OpenType math font> ...
to produce a minimal broken example.The problem
latex2e/required/amsmath/amsmath.dtx
Line 732 in e09c9d4
When
\Umathfractiondelsize\displaystyle=\z@
, the above expands to2.39\fontdimen62.39\tw@
, which is ridiculous.The fix
The text was updated successfully, but these errors were encountered: