# too many math alphabets used in version bold (can't find a solution)

I know this is a common problem, but I searched for a solution and can't find one. I tried to play with bmmax/hmmax but it does not help. Below is the minimum part of the code to reproduce the problem. I would be grateful for any advice/help.

\documentclass[12pt]{article}
\newcommand{\bmmax}{2}
\newcommand{\hmmax}{0}

\usepackage{array,float,epsf,latexsym,psfrag,amssymb,eurosym,theorem,amsmath,verbatim}

\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{bbm}
\usepackage{mathrsfs}

\usepackage[dvips]{color}
\usepackage[ansinew]{inputenc}
\usepackage{srcltx}

\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}

\def\bsf  #1{           \mbox{\boldmath $\sf #1$}}
\def\bsfh #1{\widehat  {\mbox{\boldmath $\sf #1$}}}

\begin{document}

$$\bsf x ~ \bsfh x$$

\end{document}


P.S. I have a 70-pages document which compiles fine but as soon as I delete some first 40 pages with formulas I encounter that error. That's something I can't explain to myself.

-

That definition of \bsf and \bsfh produces many more errors, not only the "Too many math alphabets" one.

Actually the error is caused by your definition of \bsfh, that causes a loop which is stopped by the "Too many math alphabets" error and at the end prints the required symbol correctly (but doing so it exhausts the number of math families in the \boldmath version).

A more sensible definition for \bsf and \bsfh can be

\DeclareMathAlphabet{\bsf}{OT1}{cmss}{bx}{n}
\newcommand{\bsfh}[1]{\widehat{\bsf{#1}}}


that shouldn't cause the problem with math alphabets (I checked and only 9 out of 16 are used). In this way \bsf{x} will give correct results also in subscripts and superscripts. Shouldn't you need them in such positions, a simpler definition can be used:

\newcommand{\bsf}[1]{\mbox{\normalfont\sffamily\bfseries #1}}
\newcommand{\bsfh}[1]{\widehat{\bsf{#1}}}


Don't load latexsym, which is obsolete (so doing you'll reduce the math alphabet usage); the symbols it provides are available through amssymb.

-
Thank you for your corrections. Frankly, I have a lot of similar 'wrong' definitions with '\rm' '\mit' '\cal' and without any font change. Could you roughly say how DeclareMathAlphabet will look like? –  Denis Mar 19 '12 at 7:52
@Denis Never underestimate error messages, even if the output looks right. Never use \rm, \sf, \it and similar two letter commands in math mode; use \mathcal{A} and not \cal A. –  egreg Mar 19 '12 at 7:58
ok. so is this \newcommand{\tv}[1]{\mbox{\boldmath $\mathcal{#1}$}} a proper way to write or should I do it somehow with \DeclareMathAlphabet ? –  Denis Mar 19 '12 at 9:37
@Denis You should load the package bm and say \newcommand{\tv}[1]{\bm{\mathcal{#1}}}. –  egreg Mar 19 '12 at 9:43
ok, thank you very much! –  Denis Mar 19 '12 at 10:35