1

When I use unicode-math, I found that there is no default performance of \mathcal in the 6 fonts given in texdoc unimath-symbols.

\documentclass{article}
\begin{document}
    $ \mathcal{DBFT} $
\end{document}

The code above will output

enter image description here

I found that unicode-math gives same performance of \mathcal and \mathscr

\documentclass{article}
\usepackage{unicode-math}
\begin{document}
    $ \mathcal{DBFT}, \mathscr{DBFT} $
\end{document}

enter image description here

I found a solution on TeX.SE:

\documentclass{article}
\usepackage{unicode-math}
\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
\begin{document}
$ \mathcal{DBFT}, \mathscr{DBFT} $
\end{document}

enter image description here

However that leads to a new problem. I can't put \tilde accent on \mathcal characters:

\documentclass{article}
\usepackage{unicode-math}
\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
\begin{document}
$ \tilde{\mathcal{B}} $

% $ \hat{\mathcal{B}} $
\end{document}

After compiling with XeLaTeX, it gave an error:

! Internal error: bad native font flag in `map_char_to_glyph'

Now I can use \tilde{\text{$ \mathcal{B} $}} to solve the problem, but this solution seems weird.

My requests:

  1. I want to use the default \mathcal style of Computer Modern when I use unicode-math package (the first figure in this Question);

  2. I want to use \tilde{\mathcal{B}} straight to put accent on \mathcal{B}.

Here is the same issue on GitHub (https://github.com/CTeX-org/forum/issues/179)

1 Answer 1

3

You found a solution for legacy fonts that isn’t compatible with unicode-math.

Since Unicode maps \mathcal and \mathscr to the same characters, you can only set them to different alphabets if you load a new font with the range= option of \setmathfont. For example, this uses New Computer Modern Book for everything but \mathscr and \mathbfscr, which it takes from a stylistic set of STIX Two Math:

\documentclass{article}
\usepackage{unicode-math}

\setmainfont{NewComputerModernBook}
\setmathfont{NewCMMath-Book}
\setmathfont{STIX Two Math}[
  range={scr,bfscr},
  Scale=MatchUppercase,
  StylisticSet=1 ]

\begin{document}
\[ \tilde{\mathcal{B}} \; \hat{\mathcal{B}} \; \mathscr{B} \]
\end{document}

Script font sample

Since it’s now loading all its alphabets from an OpenType math font, math accents work correctly.

2
  • Well, I'd like to use the font of \mathcal like the style which the first figure displays. I don't know what font is it , I use \DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n} can make the character performs what I want, but can't have accent on it.
    – Syvshc
    Jan 11, 2021 at 9:36
  • 1
    @Syvshc I don’t think any OpenType font exactly duplicates the default \mathcal. Both Latin Modern and New Computer Modern base theirs on Hermann Zapf’s AMS Euler.
    – Davislor
    Jan 11, 2021 at 13:05

You must log in to answer this question.

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