# When using unicode-math, how do I get the original calligraphic alphabet back?

I am happy with the great majority of what unicode-math does. But at times I find that I prefer a symbol the way it was before. With \varnothing and \complement, for example. In those cases I was able to save them under a different name before loading unicode-math, but this doesn't always work.

Right now I'm trying to access the \mathcal alphabet from plain LaTeX. How might I accomplish this?

I've been looking through unicode-math, trying to figure out where exactly the original \mathcal alphabet gets discarded, but I eventually gave up.

It would be interesting if someone could explain:

• how/where the original \mathcal font is defined anyway, and
• what kind of 'switch' is thrown by unicode-math that makes it unavailable.
• You can't, unless you are using CM Math (then it will be default) See also this question: tex.stackexchange.com/questions/120065/… – Henri Menke Aug 7 '13 at 21:33
• @HenriMenke Hm... But the comments there imply that you cannot use Computer Modern at all if you use unicode-math. So what do you mean by "unless"? --- Anyway, the notion that there's no way to do it is so silly I reject it. Even if I cannot just load it as a font, I could patch unicode-math to leave \mathcal alone or, as a last resort, I could typeset the alphabet in a box before loading unicode-math and then use the box. --- But I have to believe there are more elegant solutions than that. – mhelvens Aug 7 '13 at 21:46
• Let me cite the following comment from the linked question: »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« Please note, that Khaled Hosny is one of the original developers of unicode-math. Saving the alphabet to a box might indeed be possible, but will for sure bring several downsides. – Henri Menke Aug 8 '13 at 10:35
• I read those comments. And I have no doubt Khaled is right in that there is no standard option through the unicode-math interface by which the original font can be retrieved (perhaps there should be). But I would even be happy with a patch or 'hack' – one which is more elegant than using boxes. --- Indeed, storing those characters in boxes has downsides. I mention some in my answer below. --- Anyway, thanks for your help! – mhelvens Aug 8 '13 at 12:45
• @mhelvens The problem is that the entire math font mechanism is altered to deal with Unicode math fonts. For 'traditional' TeX, you simply change the family (\mathcal boils down to \fam2, at least 'out of the box'). That simply doesn't work once you switch to the Unicode mechanism, which doesn't use families at all. – Joseph Wright Aug 8 '13 at 12:56

Just override the declarations with the original one:

\documentclass{article}

\usepackage{unicode-math}

\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}

\begin{document}
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$
\end{document}


This is the output of pdffonts, showing that cmsy is used.

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
GQWLIO+CMSY10                        Type 1C           Builtin          yes yes no       4  0
NCPDNV+CMSY7                         Type 1C           Builtin          yes yes no       5  0
BZNGBB+CMSY5                         Type 1C           Builtin          yes yes no       6  0
MMERCJ+LMRoman10-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      8  0

• And I guess this is the actual answer. Thanks! :-) – mhelvens Apr 21 '16 at 20:53
• @mhelvens Sorry for being late; but maybe this wouldn't have worked at the time. – egreg Apr 21 '16 at 20:54
• That's fine. I found a different solution at the time. And right now it's best to keep the Q&A's current. – mhelvens Apr 22 '16 at 14:27

I'll just share the solution I'm using at the moment. It's far from ideal, but it's fine if you only need a few letters of the calligraphic alphabet. For example, I need only D, F, I and P throughout my document:

\documentclass{article}

\makeatletter
\newcommand\preserveCal[2]{
\expandafter\newsavebox\csname box@\string#1\endcsname
\expandafter\savebox\csname box@\string#1\endcsname{\ensuremath{\mathcal{#2}}}
\expandafter\def\expandafter#1\expandafter
{\expandafter\usebox\csname box@\string#1\endcsname}
}
\preserveCal{\calD}{D}
\preserveCal{\calF}{F}
\preserveCal{\calI}{I}
\preserveCal{\calP}{P}
\makeatother

\usepackage{unicode-math}

\begin{document}
\noindent$\mathcal{DFIP}$\par
\noindent$\calD\calF\calI\calP$
\end{document}


This is a generally applicable 'last resort' way to preserve symbols that are destroyed by a package. The problem is that these don't scale with the font. Also, each symbol takes up a whole box register, and I believe there are only 256 box registers available.

• I generally don't like to accept my own answers on SE, especially not this one. But since it is the only answer I've found that actually works, I will. If someone else shares a more elegant answer in the future, I'll happily surrender the green tick. – mhelvens Aug 11 '13 at 13:09

Very late answer, but you could also locally set the mathcodes of the letters to the ones plain TeX defines. Then you load the Computer Modern Calligraphic fonts and redefine \mathcal to locally switch to this family and use the “legacy” mathcodes.

This solution is superior to the other answer, because you obtain proper scaling of the calligraphic letters in sub/superscripts.

\documentclass{article}

\usepackage{unicode-math}

\newtoks\legacymathcodes\legacymathcodes={
\mathcodeA="7141 \mathcodeB="7142 \mathcodeC="7143
\mathcodeD="7144 \mathcodeE="7145 \mathcodeF="7146
\mathcodeG="7147 \mathcodeH="7148 \mathcodeI="7149
\mathcodeJ="714A \mathcodeK="714B \mathcodeL="714C
\mathcodeM="714D \mathcodeN="714E \mathcodeO="714F
\mathcodeP="7150 \mathcodeQ="7151 \mathcodeR="7152
\mathcodeS="7153 \mathcodeT="7154 \mathcodeU="7155
\mathcodeV="7156 \mathcodeW="7157 \mathcodeX="7158
\mathcodeY="7159 \mathcodeZ="715A
}

\font\tensy=cmsy10
\font\sevensy=cmsy7
\font\fivesy=cmsy5
\newfam\cmcalfam
\textfont\cmcalfam=\tensy
\scriptfont\cmcalfam=\sevensy
\scriptscriptfont\cmcalfam=\fivesy
\protected\def\mathcal#1{{\fam\cmcalfam
\the\legacymathcodes #1}}

\begin{document}
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$
\end{document}


If you don't want to type all the mathcodes, e.g. in case you want to extend it to lowercase as well (which CM doesn't have), you could also set the mathcodes in a loop.

\documentclass{article}

\usepackage{unicode-math}

\font\tensy=cmsy10
\font\sevensy=cmsy7
\font\fivesy=cmsy5
\newfam\cmcalfam
\textfont\cmcalfam=\tensy
\scriptfont\cmcalfam=\sevensy
\scriptscriptfont\cmcalfam=\fivesy
\protected\def\mathcal#1{%
\begingroup
\fam\cmcalfam
\count0=A
\loop\ifnum\count0<\numexprZ+1\relax
\mathcode\count0=\the\numexpr"7141 - A + \count0\relax
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$

• @mhelvens I improved my answer. Especially note, that I have changed \def\mathcal to \protected\def\mathcal, which is more appropriate since assignments happen inside \mathcal`. – Henri Menke Apr 21 '16 at 8:04