# New locally defined mathcal font for math equations

I want to make use of math fonts of mathcal namely: "pxtx" and "dutchcal" which is elaborated in this nice answer. However, I don't want to change the standard mathcal font but just use locally these fonts. How can I do that?

Some additional info. due to @Mico:

1) I use amsfont package. The F in the figure below is in the standard standard mathcal font:

2) document class: IEEEtran

3) pdfLaTeX

4) I use \mathbb

• Please tell us what the "standard mathcal" font of your document is at present.
– Mico
Jul 20 '19 at 10:40
• Please also indicate (a) which document class you employ, (b) whether you employ pdfLaTeX, XeLaTeX, or LuaLaTeX (or something else entirely) to compile your document, and (c) if your document makes use of \mathfrak and/or \mathbb. (The reason I ask question (c) is that it's not all that straightforward to have several script or calligraphic math alphabets all at once.)
– Mico
Jul 20 '19 at 10:49
– Amin
Jul 20 '19 at 12:44
• I’m not sure what you mean, “Just use locally.” Do you actually need to use three different calligraphic alphabets in the same document? Jul 20 '19 at 19:16
• @Davislor -- (totally off topic) The AMS once published a small monograph in which the authors had used five different lowercase script "p"s (no other letters), each with a very distinct (but somewhat related) definition, and refused to change their notation. I'm not at all sure how many readers were able to distinguish between the various shapes; some of them were different only in very subtle ways, so when one of the more similar glyphs appeared in isolation, I hope that it was clear from context which was meant. Authors have their own ideas, and often won't budge. Jul 24 '19 at 1:33

I’m not sure I understand your question properly. If you need to use two different calligraphic alphabets in the same document, the easiest way to accomplish this is to load one as \mathcal and the other as \mathscr in mathalpha. (On older installations, you might need to use its older name, mathalfa.)

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[cal = pxtx, scr = dutchcal]{mathalpha}

\begin{document}

pxtx: $$\mathcal{ABC}$$

dutchcal: $$\mathscr{ABC}$$

\end{document}


However, I’m not sure whether you meant that you need to use three very-similar calligraphic alphabets in the same document. (Unless it’s a specimen of different math scripts, I can’t imagine why.)

In that case, use \DeclareMathAlphabet with the proper family and encoding names. I adapted the code in mathalpha.sty:

\documentclass{article}
\usepackage[T1]{fontenc}

% Based on the code from mathalpha.sty:

\DeclareFontFamily{U}{dutchcal}{\skewchar \font =45}
\DeclareFontShape{U}{dutchcal}{m}{n}{
<-> dutchcal-r}{}
\DeclareFontShape{U}{dutchcal}{b}{n}{
<-> dutchcal-b}{}
\DeclareMathAlphabet{\mdutchcal}{U}{dutchcal}{m}{n}
\SetMathAlphabet{\mdutchcal}{bold}{U}{dutchcal}{b}{n}
\DeclareMathAlphabet{\mdutchbcal} {U}{dutchcal}{b}{n}

\DeclareFontFamily{U}{txcal}{\skewchar \font =45}
\DeclareFontShape{U}{txcal}{m}{n}{
<-> txr-cal}{}
\DeclareFontShape{U}{txcal}{b}{n}{
<-> txb-cal}{}
\DeclareMathAlphabet{\mtxcal}{U}{txcal}{m}{n}
\SetMathAlphabet{\mtxcal}{bold}{U}{txcal}{b}{n}
\DeclareMathAlphabet{\mtxbcal} {U}{txcal}{b}{n}

\begin{document}

pxtx: $$\mtxcal{ABC}$$

dutchcal: $$\mdutchcal{ABC}$$

mathcal: $$\mathcal{ABC}$$

\end{document}


If one of your packages is changing \mathcal and you need to restore it, see this question. You can also save the original definition of \mathcal with \let and \renewcommand\mathcal.

Be aware that legacy LaTeX only allows you to declare a limited number of math alphabets. One way to work around this is to load a script font as a text font (for example, a Fraktur font from oldgerm) and use it in math mode by wrapping it in \text from amsmath.

In the modern toolchain with unicode-math, you can use \setmathfontface to create as many new math alphabets as you want. You can also \setmathfont[range=cal, Scale=MatchUppercase]{Some Font} and \setmathfont[range=scr, Scale=MatchUppercase]{Another Font} to load a new script alphabet. Indeed, if you don’t do one or the other, they’ll be set to the same face by default.