# Replace mathcal plus margin-note results in \reserved@a does not match definition

This is related to problem with \mathcal in MIT Thesis package; I posted the below MWE there, but the edit was rejected due to deviating from the original authors post. IDK if its the right thing to ask a new question then, but please correct me, if I'm wrong.

I'm using a thesis template with the mathdesign math fonts but do not like the mathcal fonts, so I want to replace them. Following 219091 and 223843 I tried the

\let\mathcal\undefined
\DeclareMathAlphabet{\mathcal}{OMS}{zplm}{m}{n}


fix, but this results in the following error:

! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathcal  \fi \use@mathgrou...
l.23 $\mathcal{A}$
?


It looks like it is connected to using math in the bibliography, as the following MWE suggests. This was the closest example I could come up with, abstracting most of the template stuff (one particular thing here is that citations are printed to the margin -- removing this patch to the cite command also removes the error, but I want to keep this patched cite)

\begin{filecontents}{\jobname.bib}
@misc{example,
author    = {Example},
title     = {$\mathbf{F}_2^n$},
}
\end{filecontents}
\documentclass{article}
\usepackage[charter]{mathdesign}
\let\mathcal\undefined
\DeclareMathAlphabet{\mathcal}{OMS}{zplm}{m}{n}
\usepackage{biblatex}
\DeclareCiteCommand{\cite}[]{}{\marginpar{\footnotesize\printfield[citetitle]{labeltitle}}}{}{}
\begin{document}
$\mathcal{A}$
\cite{example}
$\mathcal{A}$
\end{document}


Removing the \footnotesize in the margin note also seem to solve the problem, but here, too, I would like to stick with the font size.

Undefining the \mathcal command is a bad hack, and you get punished for it. Change the alphabet with \SetMathAlphabet:

\begin{filecontents}{\jobname.bib}
@misc{example,
author    = {Example},
title     = {$\mathbf{F}_2^n$},
}
\end{filecontents}
\documentclass{article}
\usepackage[charter]{mathdesign}
\SetMathAlphabet{\mathcal}{normal}{OMS}{zplm}{m}{n}

\usepackage{biblatex}
$\mathcal{A}$
$\mathcal{A}$