# XeTeX: What happened to \mathcal and \mathscr?

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}


# New code

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


# 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

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.

-
Ha-haa! This is something I have wondered as well, as if it doesn't use multiple families, how do you choose the different variants ie +ssalt for cal – morbusg Jun 19 '13 at 19:47

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}


# 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}


# 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}


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.

-
In your examples you loaded XITS Math, how can I obtain \mathcal from Computer Modern? – Henri Menke Jun 19 '13 at 20:14
@HenriMenke: You can’t use Computer Modern with unicode-math, the last example you get it from Latin Modern Math which is the closest you can get. – Khaled Hosny Jun 19 '13 at 20:16
Okay, thank you anyway. I normally use TeX Gyre Pagella Math, but I don't like its script alphabet, so I wanted to fall back to CM, but it seems like I have to stick with XITS. – Henri Menke Jun 19 '13 at 20:18
@HenriMenke In the second example you can replace the second XITS Math with Latin Modern Math if it is good for you (and the first one with TeX Gyre Pagella Math of course). – Khaled Hosny Jun 19 '13 at 20:23

You can use different fonts for different ranges; XITS Math has the calligraphic letters similar to the usual ones.

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


-

When Unicode added the Math Alphabet block they decided not to treat script and calligraphic as different, I think unicode-math more or less as a design principle follows that.

If you look in the log you see

Missing character: There is no 𝐶 in font rsfs10!


where that C is MATHEMATICAL ITALIC CAPITAL C (U+1D436)

You need to get back to a normal ASCII C for rsfS, this works although there may be more elegant ways

$\mathcal{C} = \mathscr{\char\C}$
`

-
Actually the other two answers are better than this, I deleted it but I decided to undelete it as it shows a way of getting rsfs back if you decide you want exactly that font alongside unicode-math. – David Carlisle Jun 19 '13 at 20:08