Skip to content
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

Wrong angle bracket sizes with XITS and mathtools #277

Open
AndrewSwann opened this issue Sep 16, 2014 · 7 comments
Open

Wrong angle bracket sizes with XITS and mathtools #277

AndrewSwann opened this issue Sep 16, 2014 · 7 comments

Comments

@AndrewSwann
Copy link

AndrewSwann commented Sep 16, 2014

The following document produces angle brackets at the same size with and without \big. Removing mathtools or switching to TeX Gyre Pagella Math removes the problem. Nor is a problem at size \Big.

r

\documentclass{article}

\usepackage{mathtools,unicode-math}
\unimathsetup{math-style=TeX}
\setmathfont{XITS Math}
%\setmathfont{TeX Gyre Pagella Math}

\begin{document}
  \begin{displaymath}
    \bigl\langle \langle p \rangle \bigr\rangle
    \quad \bigl( ( r ) \bigr)
    \quad \bigl\{ \{ s \} \bigr\}
  \end{displaymath}

\end{document}

Output of \listfiles:

File List
article.cls 2007/10/19 v1.4h Standard LaTeX document class
size10.clo 2007/10/19 v1.4h Standard LaTeX file (size option)
mathtools.sty 2014/07/16 v1.15 mathematical typesetting tools
keyval.sty 2014/05/08 v1.15 key=value parser (DPC)
calc.sty 2007/08/22 v4.3 Infix arithmetic (KKT,FJ)
mhsetup.sty 2010/01/21 v1.2a programming setup (MH)
amsmath.sty 2013/01/14 v2.14 AMS math features
amstext.sty 2000/06/29 v2.01
amsgen.sty 1999/11/30 v2.0
amsbsy.sty 1999/11/29 v1.2d
amsopn.sty 1999/12/14 v2.01 operator names
unicode-math.sty 2014/06/30 v0.7f Unicode maths in XeLaTeX and LuaLaTeX
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
expl3.sty 2014/09/15 v5423 L3 programming layer (loader)
expl3-code.tex 2014/09/15 v5423 L3 programming layer
etex.sty 1998/03/26 v2.0 eTeX basic definition package (PEB)
l3unicode-data.def 2014/08/12 v5276 L3 Unicode data
l3pdfmode.def 2014/08/24 v5366 L3 Experimental driver: PDF mode
xparse.sty 2014/09/15 v5423 L3 Experimental document command parser
l3keys2e.sty 2014/09/15 v5423 LaTeX2e option processing using LaTeX3 keys
fontspec.sty 2014/06/21 v2.4a Font selection for XeLaTeX and LuaLaTeX
luaotfload.sty 2014/08/10 v2.5-4 OpenType layout system
luatexbase.sty 2013/05/11 v0.6 Resource management for the LuaTeX macro progr
ammer
luatex.sty 2010/03/09 v0.4 LuaTeX basic definition package (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
luatex-loader.sty 2010/03/09 v0.4 Lua module loader (HO)
luatexbase-compat.sty 2011/05/24 v0.4 Compatibility tools for LuaTeX
luatexbase-modutils.sty 2013/05/11 v0.6 Module utilities for LuaTeX
luatexbase-loader.sty 2013/05/11 v0.6 Lua module loader for LuaTeX
luatexbase-regs.sty 2011/05/24 v0.4 Registers allocation for LuaTeX
luatexbase-attr.sty 2013/05/11 v0.6 Attributes allocation for LuaTeX
luatexbase-cctb.sty 2013/05/11 v0.6 Catcodetable allocation for LuaTeX
luatexbase-mcb.sty 2013/05/11 v0.6 Callback management for LuaTeX
fontspec-patches.sty 2014/06/21 v2.4a Font selection for XeLaTeX and LuaLaTeX

fontspec-luatex.sty 2014/06/21 v2.4a Font selection for XeLaTeX and LuaLaTeX fontenc.sty
eu2enc.def 2010/05/27 v0.1h Experimental Unicode font encodings
eu2lmr.fd 2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty 2011/09/09 v0.981 provides access to latin accents and many othe
r characters in Unicode lower plane
eu2lmss.fd 2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty 2014/04/25 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
fontspec.cfg
catchfile.sty 2011/03/01 v1.6 Catch the contents of a file (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
fix-cm.sty 2014/06/10 v1.1r fixes to LaTeX
ts1enc.def 2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
filehook.sty 2011/10/12 v0.5d Hooks for input files
unicode-math-luatex.sty
lualatex-math.sty 2014/08/18 v1.4 Patches for mathematics typesetting with Lu
aLaTeX
etoolbox.sty 2011/01/03 v2.1 e-TeX tools for LaTeX
unicode-math-table.tex
t3cmr.fd 2001/12/31 TIPA font definitions
supp-pdf.mkii
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live


@RuixiZhang42
Copy link

RuixiZhang42 commented Mar 24, 2019

I’m surprises that you’ve missed \bigg and \Bigg. They are also wrong. But this is not a problem of unicode-math.

If anything, I’d say this is a design flaw with XITS Math. The original Computer Modern had \big, \Big, \bigg and \Bigg at vertical sizes 1.2em, 1.8em, 2.4em and 3.0em, respectively. The amsmath package (and therefore mathtools) does the following:

\renewcommand{\big}{\bBigg@\@ne}
\renewcommand{\Big}{\bBigg@{1.5}}
\renewcommand{\bigg}{\bBigg@\tw@}
\renewcommand{\Bigg}{\bBigg@{2.5}}

where \bBigg@ applies the multiplier to \big@size, and \big@size stores 1.2 times the total height of a normal math parenthesis (usually 1em).

Inspecting XITSMath-Regular.otf, I found that the \big, \Big, \bigg and \Bigg sizes were designed at 1.230em, 1.845em, 2.460em and 3.075em, respectively. However, the normal parenthesis is only 0.853em tall. This causes your problem. Indeed, redefining \big and friends seems to do the job:

% !TeX program = XeLaTeX
\documentclass{article}
\usepackage{mathtools,unicode-math}
\unimathsetup{math-style=TeX}
\setmathfont{XITS Math}

\makeatletter
\renewcommand{\big} {\bBigg@{1.201641}} % 1.230/(1.2*0.853)
\renewcommand{\Big} {\bBigg@{1.802462}} % 1.845/(1.2*0.853)
\renewcommand{\bigg}{\bBigg@{2.403283}} % 2.460/(1.2*0.853)
\renewcommand{\Bigg}{\bBigg@{3.004103}} % 3.075/(1.2*0.853)
\makeatother

\newcommand*\test[3]{%
  \Biggl#1\biggl#1\Bigl#1\bigl#1#1%
  #2%
  #3\bigr#3\Bigr#3\biggr#3\Biggr#3%
}

\begin{document}
  \begin{displaymath}
    \test\langle p\rangle
    \quad
    \test(r)
    \quad
    \test\{s\}
  \end{displaymath}
\end{document}

test

This should be reported to https://github.com/alif-type/xits/issues @khaledhosny ?

@RuixiZhang42
Copy link

I guess unicode-math could patch this, like it has patched \substack/subarray from amsmath.

@AndrewSwann
Copy link
Author

Thank you. I'll report this to the XITS issue tracker and see what response that gives.

@davidcarlisle
Copy link
Member

I'd say that this is a flaw in the tex support rather than the font, surely a font designer should be free to design smaller brackets, In classic tex each math font typically has a supporting package but here unicode-math is trying to cover all otf math fonts , it could of course special case xits fonts but i wonder if more generally it could define \big and friends after checking the size of a standard () ?

@RuixiZhang42
Copy link

@davidcarlisle

I'd say that this is a flaw in the tex support rather than the font

True, but then amsmath is to be blamed here… Well, Knuth’s plain.tex uses fixed sizes for \big and friends, which only works for 10pt CM, and amsmath at least tries to make them scalable. But the assumption that \big( is exactly 1.2 times larger than a normal ( is clearly based on CM, so it cannot be generalized to other OT fonts.

but i wonder if more generally it could define \big and friends after checking the size of a standard () ?

Actually, there’s a simpler way: Instead of redefining \big and friends, we could just change how \big@size is defined:

\documentclass{article}
\usepackage{mathtools,unicode-math}
\unimathsetup{math-style=TeX}
\setmathfont{XITS Math}

\makeatletter
\ExplSyntaxOn

\tl_new:N \g_@@_big_to_normal_size_ratio_tl

\tl_gset:Nn \g_@@_big_to_normal_size_ratio_tl
  {
    \fp_eval:n { 1.230 / 0.853 } % 1.441969519343493552168815943728
  }

\addto@hook\every@math@size{%
  \global\big@size \g_@@_big_to_normal_size_ratio_tl\ht\Mathstrutbox@
  \global\advance\big@size \g_@@_big_to_normal_size_ratio_tl\dp\Mathstrutbox@ }

\ExplSyntaxOff
\makeatother

\newcommand*\test[3]{%
  \Biggl#1\biggl#1\Bigl#1\bigl#1#1%
  #2%
  #3\bigr#3\Bigr#3\biggr#3\Biggr#3%
}

\begin{document}
  \begin{displaymath}
    \test\langle p\rangle
    \quad
    \test(r)
    \quad
    \test\{s\}
  \end{displaymath}
\end{document}

In practice, though, \g_@@_big_to_normal_size_ratio_tl would be font dependent of course.

@stone-zeng
Copy link
Contributor

I am not sure how to calculate the values for \big and friends. If the font contains more than 5 sizes of brackets, how to assign these commands to the glpyhs? Clearly it's not necessary to make \bigggg etc.

@RuixiZhang42
Copy link

RuixiZhang42 commented Mar 24, 2019

@stone-zeng It appears that Fira Math uses non-conventional sizes for the delimiters, which is a good thing (because the preferred line spacing for Fira is 1.4). All extensible delimiters can be accessed via the \left<del>...\right<del> construct. However, there are way too many intermediate sizes IMHO. Under the default \delimiterfactor=901, size 8 and larger all come too late.

Again, the only patch unicode-math can provide is perhaps just \g_@@_big_to_normal_size_ratio_tl. The rest should be addressed by the font itself.

\documentclass{article}
\usepackage{xcolor,amsmath,unicode-math}
\setmathfont{FiraMath-Regular.otf}
\makeatletter
\ExplSyntaxOn
\tl_new:N \g_@@_big_to_normal_size_ratio_tl
\tl_gset:Nn \g_@@_big_to_normal_size_ratio_tl
  {
    \fp_eval:n { 1.319 / 0.990 } % FiraMath-Regular.otf
  }
\addto@hook\every@math@size{%
  \global\big@size \g_@@_big_to_normal_size_ratio_tl\ht\Mathstrutbox@
  \global\advance\big@size \g_@@_big_to_normal_size_ratio_tl\dp\Mathstrutbox@ }
\ExplSyntaxOff
\def\big{\bBigg@{1}}
\def\Big{\bBigg@{1.497}}
\def\bigg{\bBigg@{1.995}}
\def\Bigg{\bBigg@{2.492}}
\def\vast{\bBigg@{2.989}}
\def\vastl{\mathopen\vast}\def\vastm{\mathrel\vast}\def\vastr{\mathclose\vast}
\def\Vast{\bBigg@{3.487}}
\def\Vastl{\mathopen\Vast}\def\Vastm{\mathrel\Vast}\def\Vastr{\mathclose\Vast}
\def\VAST{\bBigg@{3.984}}
\def\VASTl{\mathopen\VAST}\def\VASTm{\mathrel\VAST}\def\VASTr{\mathclose\VAST}
\def\VASTT{\bBigg@{4.482}}
\def\VASTTl{\mathopen\VASTT}\def\VASTTm{\mathrel\VASTT}\def\VASTTr{\mathclose\VASTT}
\makeatother
\newcommand*\testbig[1]{%
  \vcenter{\hrule height0.990em width0.4pt}%
  #1%
  \vcenter{\color{red}\hrule  height1.319em width0.4pt}%
  \bigr#1%
  \vcenter{\color{blue}\hrule height1.647em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height1.975em width0.4pt}%
  \Bigr#1%
  \vcenter{\color{blue}\hrule height2.303em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height2.631em width0.4pt}%
  \biggr#1%
  \vcenter{\color{blue}\hrule height2.959em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height3.287em width0.4pt}%
  \Biggr#1%
  \vcenter{\color{blue}\hrule height3.615em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height3.943em width0.4pt}%
  \vastr#1%
  \vcenter{\color{blue}\hrule height4.271em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height4.599em width0.4pt}%
  \Vastr#1%
  \vcenter{\color{blue}\hrule height4.927em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height5.255em width0.4pt}%
  \VASTr#1%
  \vcenter{\color{blue}\hrule height5.583em width0.4pt}\,%
  \vcenter{\color{red}\hrule  height5.912em width0.4pt}%
  \VASTTr#1%
}
\delimiterfactor=945\relax % need to be > 1000*5.583/5.912
\parindent=0pt\relax
\begin{document}
$\testbig)$
$\testbig\rangle$
$\testbig\}$\par
Note:\par
1.\ Normal size is shown (black).\par
2.\ Only ext.\ sizes~1, 3, 5, \dots, 15 (red) are shown.\par
3.\ Too many intermediate sizes (blue), causing\\
\verb|\delimiterfactor=945| must be issued.
\end{document}

gh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants