2

I am using the implementation I found from this website to write a document in the Calibri font, including the math mode. It looks wonderful, however there is one major flaw: the "large" symbols don't scale properly. This includes integral signs and parentheses.

MWE:

\documentclass[10pt]{article}
\usepackage{amsmath}  % Same for amsmath.
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont[Mapping=tex-text,Ligatures={NoRequired,NoCommon,NoContextual}]{Calibri}
\setmathfont[slash-delimiter=frac]{Cambria Math}
\setmathfont[range={"0000-"FFFF}]{Calibri}
\setmathfont[range=up]{Calibri}
\setmathfont[range=sfup]{Calibri}
\setmathfont[range=it]{Calibri Italic}
\setmathfont[range=bfup]{Calibri Bold}
\setmathfont[range=bfit]{Calibri Bold Italic}
\setsansfont{Calibri}  % Make \mathsf and \textsf also Calibri

\begin{document}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit...
    \[ x^2y = 2z\left(\frac{\alpha \beta^2}{73c}\right)^2 \]
    \[ \frac{d}{dx}\int f(x)\,dx = f(x) \]
\end{document}

Is there any easy way to fix this? If there's no simple general solution, it would also be fine to just fix the parentheses, as for my purposes the other "large" symbols don't occur.

Thanks in advance.

PS: I'm using this slightly weird implementation instead of, say the sansmath package, or using the cmbright font, as I subjectively prefer the look that it gives. Also, it's better compatible with the Calibri font which I'm using for the main text.

9
  • 1
    \setmathfont[range={"0000-"FFFF}]{Calibri}looks rather odd, that's replacing the whole basic plane by Calibri so you are hardly using the declared Cambria Math at all, in particular () are no longer coming from a math font with declared extensible characters. Jan 4, 2022 at 16:34
  • @DavidCarlisle I think that was done in order for Cambria Math to be used for the horizontal lines in fractions, as explained in the linked website (and Calibri for everything else, which is the desired outcome). But I'm of course happy to accept alternative implementations if you think that was a bad idea.
    – YiFan
    Jan 4, 2022 at 16:39
  • well I don't know what final outcome you want but it breaks all math typesetting except fractions as you are not using a unicode math font for anything except that. Jan 4, 2022 at 16:42
  • @DavidCarlisle I know what I'm doing is odd, but is it possible to just have a fix for the parenthesis scaling? That's the most major problem for me right now. Many thanks for your help.
    – YiFan
    Jan 4, 2022 at 16:44
  • I think it's better to say the code copied from that site is "wrong" rather than "odd" Jan 4, 2022 at 16:50

1 Answer 1

4

enter image description here

\documentclass[10pt]{article}
\usepackage{amsmath}  % Same for amsmath.
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont[Mapping=tex-text,Ligatures={NoRequired,NoCommon,NoContextual}]{Calibri}
\setmathfont[slash-delimiter=frac]{Cambria Math}
\setmathfont[range={"0000-"FFFF}]{Calibri} %removing this fixes the issue
% Or if you _really_ want to keep that, at least put the () back
\setmathfont[range={"0028-"0029}]{Cambria Math}
\setmathfont[range=up]{Calibri}
\setmathfont[range=sfup]{Calibri}
\setmathfont[range=it]{Calibri Italic}
\setmathfont[range=bfup]{Calibri Bold}
\setmathfont[range=bfit]{Calibri Bold Italic}
\setsansfont{Calibri}  % Make \mathsf and \textsf also Calibri

\begin{document}
    Lorem ipsum dolor sit amet, consectetur adipiscing elit...
    \[ x^2y = 2z\left(\frac{\alpha \beta^2}{73c}\right)^2 \]
    \[ \frac{d}{dx}\int f(x)\,dx = f(x) \]
\end{document}

Basically

\setmathfont[range={"0000-"FFFF}]{Calibri} %removing this fixes the issue

Will break the math setting as Calibri is not a Math font. You added a line to fix up (just) fractions and I added another to fix up (just) extendable () but not doing that at all would seem safer. (As your output shows \intfor example is barely usable with this setting)

1
  • Thank you so much; I guess the issue is I copy pasted code without understanding it! I'll wait a bit in case a better answer comes along, but otherwise I'll accept yours. :)
    – YiFan
    Jan 4, 2022 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .