[Tex/LaTex] New locally defined mathcal font for math equations

equationsfontsmath-fonts

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:

enter image description here

2) document class: IEEEtran

3) pdfLaTeX

4) I use \mathbb

Best Answer

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}

Font sample

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}

Three calligraphic alphabets

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.

Related Question