“Too many math alphabets” with Beamer and DeclareSymbolFont

The following is a near-minimal example of my problem:

\documentclass[dvipsnames]{beamer}

\usepackage{stmaryrd}
\usepackage{MnSymbol}

\DeclareSymbolFont{bbsymbol}{U}{bbold}{m}{n}
\DeclareMathSymbol{\bbsemi}{\mathbin}{bbsymbol}{"3B}

% Import some stuff from mathabx.sty -- because mathabx.sty incompatible with
% amsmath package.
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
<5> <6> <7> <8> <9> <10> gen * matha
<10.95> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}

\begin{document}

\begin{frame}
$\mathbf{0} \mathsf{hello}$
\end{frame}

\end{document}


I would like to be able to use stmaryrd and MnSymbol in the same doc. I would also like some stuff from mathabx, but because of incompatibility with amsmath (which is imported automatically by MnSymbol), I use DeclareSymbolFont to import it, as described in 1. Moreover I would also like to define a blackboard semicolon operator, and so I also use DeclareSymbolFont to introduce bbsymbol. Finally I want mathbf and mathsf.

Unfortunately this seems to run out of space for math alphabets in Beamer, but not (for example) if I build a regular article.

Is there a solution that meets all my requirements, for Beamer? (It seems that deleting any one of the imported or defined fonts fixes the problem, but then I don't have all my requirements satisfied.)

• You can look here for a diagnosis: tex.stackexchange.com/questions/40757/…; there are methods for loading only the needed symbols, if they are few, without wasting a math alphabet. Note that MnSymbol is rather hungry in this respect. – egreg Jul 28 '13 at 17:58
• Yes, I saw this, thanks. I managed to work around it in the end by loading what I need from stmaryrd. I wasted some time trying to do the same with MnSymbol, but as the symbol codes don't appear in the .sty file this wasn't so easy. (As an aside, I guess this is a case where a "minimal example" may not be that useful, since the best solution to this problem seems to depend on exactly how you are using the packages in question.) – Roly Jul 28 '13 at 18:06
• Can you add a self-answer describing what you did? – egreg Jan 4 '14 at 23:48
• Re the problem of looking up the symbol codes in MnSymbol, I found this helpful: texdef -tlatex -pMnSymbol lhookswarrow. The output contains \lhookswarrow: \mathchar"3436 and that tells me that the symbol is at position "36 in math alphabet "34, but you can look at the MnSymbol.sty file to see that the alphabet is MnSyA. – dubiousjim Aug 9 '14 at 12:41
• @dubiousjim Oh, that's pretty awesome to know. Thanks! – Roly Aug 9 '14 at 16:05

1 Answer

In the end I added the following after the \DeclareFontFamily business above:

% Use these in preference to stmaryrd (to avoid math alphabet limits).
\DeclareMathSymbol{\ldbrack}{3}{matha}{"76}
\DeclareMathSymbol{\rdbrack}{3}{matha}{"77}


So it looks like I pulled in the characters I needed from mathabx rather than stmaryrd in the end.

I'm not sure if this counts as an answer to my original question, but I've posted it here in case it's useful anyway.

• This does not help in my case: when I just load MnSymbol only in beamer, regardless whether I add your stuff or not, xelatex gets stuck on Latex Error: Command \mathdollar already defined. – მამუკა ჯიბლაძე Dec 11 '16 at 19:32