# “Too many math alphabets in version bold” error

I am having a hard time with the "Too many math alphabets in version bold" error. Here is the minimal working example on the latest version of Texlive that comes with Ubuntu 18.04:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}

$\widetilde{\boldsymbol{\mathsf{x}}}_n$
$$\widetilde{\boldsymbol{\mathsf{x}}}_n$$

\end{document}


I have been searching around but could not find the reason why this causes an error. It seems like having both \widetilde{\boldsymbol{\mathsf{x}}}_n in in-line and displayed equation causes this error, but I have absolutely no clues why and how to fix this :-(.

My question: Is there a way to fix this?

Any help/hint is highly appreciated.

PS 1: This error appears to be different than the one in "Too many math alphabets" error so I believe it is not a duplicate.

PS 2: As David Carlisle kindly pointed out in the comment, the first error in the log file is

! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax \ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup

• The posted code does not give the error that you show in the title. – David Carlisle Nov 29 '20 at 23:31
• I do not have that error on Ubuntu 20.04 and the TexLive that comes with it, but for some strange reason this happens on Ubuntu 18.04 and its TexLive on apt-get....According to the log file, it is TexLive 2017. – weirdo Nov 29 '20 at 23:35
• which texlive version does that give in the initial banner I could try an older system, it seems strange though: this example should get nowhere near the 16 allowed. You could show the log file from that example – David Carlisle Nov 29 '20 at 23:36
• is that the first error or fo you get ! Use of \reserved@a doesn't match its definition. first? – David Carlisle Nov 29 '20 at 23:38
• This was an error in texlive 2016 and 2017 fixed in 2018. – David Carlisle Nov 30 '20 at 0:17

I think you just need this fix

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\makeatletter
\def\@mathmeasure#1#2#3{\setbox#1\hbox{%
\m@th$#2#3$}}
\makeatother
\begin{document}
$\widetilde{\boldsymbol{\mathsf{x}}}_n$
$$\tracingall \widetilde{\boldsymbol{\mathsf{x}}}_n$$

\end{document}


note the current amsmath source says

%    As of 2018/12 release we don't turn off |\evermath| as this
%    optimization can be harmful.
% \changes{v2.17b}{2018/12/01}{Don't drop \cs{frozen@everymath}}


That could have been me, but I don't recall, perhaps it was Frank:-)

As a general rule only look at the first error reported. The math alphabet error is entirely spurious but to get it you need to step past 18!!!! earlier error messages:

! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Use of \reserved@a doesn't match its definition.
\reserved@b ->\relax
\ifmmode \else \non@alpherr \mathsf  \fi \use@mathgroup...
l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?
! Undefined control sequence.
<argument> \@nil

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
?

! LaTeX Error: Too many math alphabets used in version bold.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.8 \widetilde{\boldsymbol{\mathsf{x}}}
_n
? x

• This does fix my problem! Thank you so much!! I will keep in mind the first error in the log file when reporting issues. – weirdo Nov 30 '20 at 0:23