[Tex/LaTex] Too many symbol fonts declared error

fontsluatexmath-modesymbols

I have discovered a new package newtxmath which is sad to be better than mathptmx. I also want to use the bm package for bold Greek letters.

It works just fine with mathptmx, but causes an error with newtxmath.

Here is my document (use LuaLaTex to compile).

\documentclass[10pt,a4paper]{book}

\usepackage{bm}

\usepackage{lscape}
\usepackage{ragged2e}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{yfonts}
\usepackage{mathtools}
\usepackage{comment}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{mathabx}
\usepackage{wasysym}
\usepackage{wrapfig}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage{skull}
\usepackage{faktor}
\usepackage{xfrac} 
\usepackage{enumitem}
\usepackage{lipsum}

\usepackage[russian]{babel}
\usepackage{polyglossia}    
\defaultfontfeatures{Ligatures=TeX}

\usepackage{mathptmx}
%\usepackage{newtxmath}


\setmainfont{Georgia}
\newfontfamily\cyrillicfont{Georgia}

\usepackage{fontspec}
\setmainlanguage{russian}

\begin{document}

$$
\bm{\Phi}
$$

\end{document}

I am sorry for posting so many packages here, but I wasn't able to figure it out which package conflicts with newtxmath, because mathptmx also loads a math font, so they should both cause, or both not cause a problem (obviuosly, I am wrong here).

Searching through this site I found all answers to be too personal and too specific. Unfortunately, I couldn't apply any of those solutions to me.

Best Answer

Your preamble is a bit messy.

Loading mathabx and amssymb along with newtxmath is useless: if you load mathabx before newtxmath, most of the symbols will be redefined; in the other order, mathabx will override most of newtxmath symbols.

Also skull allocates a math symbol font just for one symbol. It doesn't seem worthy it and it's easy to do without wasting a math group.

The package loading order is very important; in some cases you get conflicts. In particular, bm should be loaded after math font packages and after amsmath.

Don't load both babel and polyglossia: they fight each other.

\documentclass[10pt,a4paper]{book}

\usepackage{fix-cm}% just to avoid some spurious messages

\usepackage{amsmath}
\usepackage{mathtools}

\usepackage{amsthm}
\usepackage{thmtools}

\usepackage{wasysym}
%\usepackage{skull} % see later
\usepackage{newtxmath}
%\usepackage{amssymb} % not with newtxmath
%\usepackage{mathabx} % not with newtxmath
\usepackage{bm}

\usepackage{lscape}
\usepackage{ragged2e}

\usepackage{faktor}
\usepackage{xfrac} 
\usepackage{enumitem}

\usepackage{yfonts}
\usepackage{comment}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\usepackage{lipsum}

%\usepackage[russian]{babel} % either babel or polyglossia
\usepackage{polyglossia}    

\setmainlanguage{russian}

\setmainfont{Georgia}
\newfontfamily\cyrillicfont{Georgia}

%%% Loading a math symbol font for just one symbol is a big waste
%%% The following lines do the same as skull.sty
\DeclareFontFamily{U}{skulls}{}
\DeclareFontShape{U}{skulls}{m}{n}{ <-> skull }{}
\newcommand{\skull}{\text{\usefont{U}{skulls}{m}{n}\symbol{'101}}}


\begin{document}

\[
\bm{\Phi}+\skull
\]

\end{document}

Finally, update your TeX system: with XeLaTeX and a properly crafted preamble it's quite rare to incur in the “Too many math fonts” error.

enter image description here

Related Question