[Tex/LaTex] How to use mathcal fonts with charter font from mathdesign

fontsmath-mode

Here's an example that uses the mathdesign package to implement the Charter fonts:

\documentclass{standalone}
\usepackage[T1]{fontenc}
\usepackage[charter]{mathdesign}
\begin{document}
   $H \quad \mathcal H \quad \mathscr H$
\end{document}

which produces this output:

enter image description here

According to this answer, I expected \mathcal and \mathscr to yield different results. How do I get fonts similar to these

enter image description here

while also using the Charter fonts. (This last image is borrowed from the answer cited above.)

Best Answer

The answer you cite is not specific to mathdesign and essentially shows the default for \mathcal. Font packages may change it.

With mathdesign, \mathcal and \mathscr are synonyms, unless the (undocumented) option cal=cmcal is passed to the package.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[charter,cal=cmcal]{mathdesign}

\begin{document}

$H \quad \mathcal{H} \quad \mathscr{H}$

\end{document}

enter image description here

Avoid \mathcal H and prefer \mathcal{H}. Trust me.


How to find the undocumented option?

The Charter font is managed with the subpackage mdbch.sty, which has

\if@MD@cmcal
\DeclareSymbolFont{mdcal}{OMS}{xmdcmsy}{m}{n}%
\SetSymbolFont{mdcal}{bold}{OMS}{xmdcmsy}{b}{n}%
\else
\DeclareSymbolFont{mdcal}{OMS}{mdbch}{m}{n}%
\SetSymbolFont{mdcal}{bold}{OMS}{mdbch}{b}{n}%
\fi
\DeclareSymbolFontAlphabet{\mathcal}{mdcal}
\DeclareSymbolFont{mdscr}{OMS}{mdbch}{m}{n}%

\DeclareSymbolFontAlphabet{\mathscr}{mdscr}%
\SetSymbolFont{mdscr}{bold}{OMS}{mdbch}{b}{n}%

Not how I'd write it, but that's a different matter. It seems reasonable that xmdcmsy refers to the Computer Modern \mathcal. Indeed, mdfont.def has

%% ----------------------------------------------------------------
%% Computer Modern Symbol
%% ----------------------------------------------------------------

  \def\MD@font@name{xmdcmsy}
  \DeclareFontFamily{OMS}{\MD@font@name}{\skewchar\font48 }
  \DeclareFontShape{OMS}{\MD@font@name}{m}{n}{%
    <5><6><7><8><9><10>sgen*[\cmsy@ratio]cmsy%
    <10.95><12><14.4><17.28><20.74><24.88> s*[\cmsy@ratio] cmsy10%
  }{}
  \DeclareFontShape{OMS}{\MD@font@name}{b}{n}{%
    <5><6><7><8><9>sgen*[\cmsy@ratio]cmbsy%
    <10><10.95><12><14.4><17.28><20.74><24.88> s*[\cmsy@ratio] cmbsy10%
  }{}
  \DeclareFontShape{OMS}{\MD@font@name}{mb}{n}{%
    <5><6><7><8><9>sgen*[\cmsy@ratio]cmbsy%
    <10><10.95><12><14.4><17.28><20.74><24.88> s*[\cmsy@ratio] cmbsy10%
  }{}

which essentially means the cmsy font is subject to a suitable scaling for making it compatible with the main font.

OK, not it's a matter to look how to make \if@MD@cmcal return true. If we look for it in mathdesign.sty, we find

%% Type of calligraphic alphabet
\newif\if@MD@cmcal  \@MD@cmcalfalse

\define@key{MD}{cal}[cmcal]{%
    \ifthenelse{\equal{#1}{cmcal}}{\@MD@cmcaltrue }
    {\ifthenelse{\equal{#1}{script}}{\@MD@cmcalfalse}{}}}

This means that if the option cal=cmcal is passed, the conditional will return true. With nothing or cal=absolutelywhatever the conditional will return false with \mathcal and \mathscr becoming synonyms.

Actually also typing just cal would do, so you can save some keystrokes and say

\usepackage[charter,cal]{mathdesign}

Why isn't this option mentioned in the manual? Who knows?