# two mathcal families in the same document

Is it possible to use two math fonts from the calligraphy families in the same document? Something like $\mathcal{P}$ from Zapfino and $\mathcal{T}$ from XITS math?

-
If my guess is right that you are using unicode-math, please add that in your question and as a tag. – Caramdir Jan 15 '11 at 17:55
@Caramdir: from the name of the fonts, it is a good guess but I am also interested in non xelatex answers. I do not want to limit my question to the use of unicode-math even though that I would be my final choice. Thanks – pluton Jan 15 '11 at 17:57
The answer is completely different depending on whether you use unicode-math or not. – Philipp Jan 15 '11 at 18:40

With unicode-math (which I assume you are using), you can remap a range of characters to a different font:

\setmathfont[range="1D4AB]{Zapfino}


(where "1D4AB is the unicode slot for the character that should be remapped (see the unicode-math manual for the syntax when you want to remap multiple characters)).

The problem is that Zapfino probably doesn't contain the U+1D4AB MATHEMATICAL SCRIPT CAPITAL P character. Hence you have to remap that character to U+0050 LATIN CAPITAL LETTER P first. I don't know if unicode-math has an interface to do that manually (Will should be able to tell). But it does that automatically if you remap a whole range of characters, like

\setmathfont[range=\mathscr]{Zapfino}


(Note that remapping \mathscr doesn't change \mathcal even though by default both display the same character.)

The height of Zapfino probably doesn't match the height of XITS Math. So you have to rescale it:

\setmathfont[range=\mathscr,Scale=MatchUppercase]{Zapfino}

-
Thanks. I also see a more problematic configuration if I need '\mathcal{P}' from Zapfino as well as '\mathcal{P}' from XITS math. – pluton Jan 16 '11 at 14:59
@pluton: with the solution above, one is \mathscr{P} the other \mathcal{P}. – Caramdir Jan 16 '11 at 17:06
ok, what about three P? – pluton Jan 16 '11 at 19:16
@pluton: then you should rethink your notation... (If you tag the question unicode-math, you have a better chance that Will Robertson (the author of unicode-math) sees it.) – Caramdir Jan 16 '11 at 19:25

It's possible. This is what mathrsfs or eucal package does. Let's take have a look at mathrsfs package:

\DeclareSymbolFont{rsfs}{U}{rsfs}{m}{n}
\DeclareSymbolFontAlphabet{\mathscr}{rsfs}


This shows how to declare a math symbol font and the font command. The first line declares that math font family rsfs is {U}{rsfs}{m}{n} in NFSS. And the second line give it a command \mathscr. It may be a bit more clear if we use a different math family name other than rsfs:

\DeclareSymbolFont{mathscript}{U}{rsfs}{m}{n}
\DeclareSymbolFontAlphabet{\mathscr}{mathscript}


or even simpler (waht it should be, I think):

\DeclareMathAlphabet{\mathscr}{U}{rsfs}{m}{n}


Please refer to fntguide for datails.

Warning: TeX allows 16 math font family only in a document. (It's too bad....) If you need more, you will have to use text mode to simulate a fake math font family. For example:

\newcommand*\mathscr[1]{\text{\usefont{U}{rsfs}{m}{n}#1}}


It works differently from math fonts, but may be useful if you have to use a lot of different typefaces of math alphabets.

-
I'm sorry I didn't notice the need of Unicode math fonts. What I said is all about traditional method. Although the traditional method can also be used in XeTeX (like Latin Modern), but unicode-math is more comfortable as @Caramdir say. – Leo Liu Jan 15 '11 at 17:57
I just added a comment saying that your answer was of interest to me too. – pluton Jan 15 '11 at 17:58