2

I'm having a problem when I try to use too many different types of math symbols in LaTeX, such as in this example:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{dsfont}
\usepackage{gensymb}
\usepackage{amssymb}
\usepackage{authblk}
\usepackage{amstext}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{upgreek}
\usepackage{textcomp}
\usepackage{bm}
\usepackage[mathscr]{euscript}
\let\euscr\mathscr \let\mathscr\relax
\usepackage[scr]{rsfso}
\usepackage{siunitx}
\usepackage[e]{esvect}
\begin{document}
$\mathbb{R}\mathscr{P}\euscr{B}\mathcal{C}\vv{x_0}$
\end{document}

When I try to compile that, the following error message appears in the terminal:

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

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

l.21 $\mathbb{R}\mathscr{P}
                           \euscr{B}\mathcal{C}\vv{x_0}$
? 

What can I do to use more alphabets? I actually need all of those math symbols in my document.

  • Are you sure your readers will be able to distinguish between \euscr{C} and \mathcal{C}? – egreg Feb 11 '17 at 13:39
  • Well, now that I look at the output, probably not. But my idea was to use \euscr{P} (I just wrote that as a minimal working example), so I would need that package anyway... And it's not only that, I actually have many more packages in my document, and there is no way to make it compile. Isn't there any way to just tell latex to use all the packages quietly, without giving errors? – Alba Crespo Pérez Feb 11 '17 at 13:46
  • 1
    I showed a trick for saving in math groups; if just one letter from an alphabet is needed, I'd go with the \DeclareRobustCommand method, rather than loading a full fledged math alphabet. – egreg Feb 11 '17 at 14:00
  • Sorry but... how does the \DeclareRobustCommand work? I'm not that much of an expert in Latex... Could you explain it a little more please? – Alba Crespo Pérez Feb 11 '17 at 14:34
  • 1
    It's a variant of \newcommand, same syntax. – egreg Feb 11 '17 at 16:13
4

First of all, remove latexsym and gensymb that add nothing really useful: the former is covered by amssymb and the latter’s symbols can easily be produced in a different way.

This already saves two math groups. Also loading dsfont is dubious, unless you want two different doublestroke fonts.

Probably also upgreek is inessential.

As a side note, amsfonts is automatically loaded by amssymb and amstext by amsmath.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{upgreek}
\usepackage{authblk}
\usepackage{textcomp}
\usepackage{bm}
\usepackage{siunitx}

% more calligraphic fonts
\usepackage[mathscr]{euscript}
\let\euscr\mathscr \let\mathscr\relax
\usepackage[scr]{rsfso}

\begin{document}

$\mathbb{R}\mathscr{P}\euscr{B}\mathcal{C}$

\end{document}

With this, the last allocated math group is 14. If you get into troubles later on, the only feasible alternative is to define some of the calligraphic fonts in a different way.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{upgreek}
\usepackage{authblk}
\usepackage{textcomp}
\usepackage{bm}
\usepackage{siunitx}

% more calligraphic fonts
\DeclareRobustCommand{\euscr}[1]{%
  \text{\usefont{U}{eus}{m}{n}#1}%
}
\DeclareRobustCommand{\mathscr}[1]{%
  \text{\usefont{U}{rsfso}{m}{n}#1}%
}

\begin{document}

$\mathbb{R}\mathscr{P}\euscr{B}\mathcal{C}$

\end{document}

No bold version, but I don't think you need it: it's already difficult to distinguish between \euscr{C} and \mathcal{C}.

  • Okay, that's a good idea, thank you! But just out of curiosity, why does latex give this error? Is it really that problematic for latex to just load all the packages? I thought there would be an easy way to avoid the error. And why does it say that there are too many packages "in version normal"? I can't upvote your answer because I don't have enough reputation in this site yet, but I will matk it as the accepted answer :) – Alba Crespo Pérez Feb 11 '17 at 14:15
  • 1
    @AlbaCrespoPérez TeX has a limitation of 16 math groups. LaTeX does its best at not allocating them when unneeded, but as soon as a math alphabet is used in the document, a math group is used up. In your case, \mathbb causes the allocation of the last available math group and the next attempt with \euscr causes the error. – egreg Feb 11 '17 at 14:19
  • 1
    actually, there might be another way. blackboard bold, usually addressed as \mathbb, is part of a font automatically loaded (and defined) by amsfonts but there is an alternative. the singular lowercase blackboard bold letter "k" is defined as \Bbbk (and it is not accessible as \mathbb{k}), and if necessary (i didn't say convenient), individual uppercase blackboard bold letters could be given their own names (which many authors do anyway) using \Bbbk as a model. – barbara beeton Feb 11 '17 at 17:04
2

enter image description here

The posted document runs without error if you use xelatex or lualatex which have 256 rather than 16 available math alphabets per math version.

0

This new answer is there only to give an example, and a heads up to this previous answer.

A complementary solution to egreg's one (cleanup first) is to reduce the number of alphabets used by bm - which in turn is used by amssymb :

\newcommand\hmmax{0}
\newcommand\bmmax{0}

before \usepackage{amssymb}

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage{dsfont}
\usepackage{gensymb}

% put these before amssymb
% to avoid ``Too many math alphabets used in version normal.''
% cf. https://tex.stackexchange.com/a/243541/91665
\newcommand{\hmmax}{0}
\newcommand{\bmmax}{0}
\usepackage{amssymb}

\usepackage{authblk}
\usepackage{amstext}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{upgreek}
\usepackage{textcomp}
\usepackage{bm}
\usepackage[mathscr]{euscript}
\let\euscr\mathscr \let\mathscr\relax
\usepackage[scr]{rsfso}
\usepackage{siunitx}
\usepackage[e]{esvect}
\begin{document}
$\mathbb{R}\mathscr{P}\euscr{B}\mathcal{C}\vv{x_0}$
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.