43

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)

1
  • 1
    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, 2013 at 19:47

3 Answers 3

39

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.

4
  • In your examples you loaded XITS Math, how can I obtain \mathcal from Computer Modern? Jun 19, 2013 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. Jun 19, 2013 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. Jun 19, 2013 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). Jun 19, 2013 at 20:23
15

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

enter image description here

1
  • 7
    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. Jun 19, 2013 at 20:08
12

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}

enter image description here

You must log in to answer this question.

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