[Tex/LaTex] XeTeX: What happened to \mathcal and \mathscr

fontsxetex

Recently I switched from pdflatex to xelatex to be able to use OpenType fonts. I like to use variables highlighted using \mathcal for specific variables, while I used to use \mathscr-typeset variables for matrices. But when I compile with XeLaTeX they look exaclty the same.

Old code

\documentclass{standalone}
\usepackage{mathrsfs}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

Output

old

New code

\documentclass{standalone}
\usepackage{unicode-math}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

Output

new

Broken code

I tried to get back the glyphs from mathrsfs, but it failed this way.

\documentclass{standalone}
\usepackage{unicode-math}
\usepackage{mathrsfs}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

Output

broken

Question: How can I get back the behaviour? In principle I'd like to have the old \mathcal letters from the pdflatex-version of Computer/Latin Modern.


Alternate solutions (Addendum 2016/05/11)

Best Answer

You have several options

Don’t use unicode-math

Unless you have a specific reason to use it, you don’t have to use it and your old code should work just fine.

\documentclass{standalone}
\usepackage{mathrsfs}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

enter image description here

Use a different math font

Some OpenType math fonts like XITS Math have both math calligraphic and math script alphabets. By default XITS Math has a math script alphabet and the math calligraphic alphabet is available through stylistic set 1. We can use unicode-math

\documentclass{standalone}
\usepackage{unicode-math}
\setmathfont{XITS Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

enter image description here

Use \mathscr from a different font

The default font, Latin Modern Math, has a math calligraphic alphabet only; we can use the math script from XITS Math. Though unicode-math loads Latin Modern Math by default, we have to explicitly use it for some reason or things will not be quite right.

\documentclass{standalone}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\setmathfont[range={\mathscr,\mathbfscr}]{XITS Math}
\begin{document}
$\mathcal{C} = \mathscr{C}$
\end{document}

enter image description here

That being said, the root of this complication is because the people who encoded Unicode math symbol could not find any convincing evidence for the use in math of both the calligraphic alphabet and the math script in the same context to mean different things, so they considered it to be just a stylistic not semantic difference so they were unified in encoding.