We all know the dreaded error message LaTeX Error: Too many symbol fonts declared.
Is there an up to date survey of why it's there, and what can be done about it?
For example, I know that macros such as \DeclareSymbolFont
gobble up some limited capacity of internally allocated counter, dating back to some magic numbers Knuth chose at the time for TeX.
I also know that newer systems (LuaTeX, XeTeX) have a higher capacity, but not for, e.g., \DeclareSymbolFont
.
There are also all kinds of tricks one can do to limit the number of font families a standard package (like bbm) loads, and so on.
Is there a source that summarises the problem and solutions/workarounds comprehensively?
If there is more than one, what is the most recent/up-to-date?
Context
I often need to extract only one (or a small number) of symbols from a font. The general advice seems to be to look up that package's sourcecode and extract the bare minimum. For example, to get the \boxright
symbols from the boisik font, we could use these four lines:
\DeclareFontFamily{U}{bskma}{\skewchar\font130 }
\DeclareFontShape{U}{bskma}{m}{n}{<->bskma10}{}
\DeclareSymbolFont{bskadd} {U} {bskma}{m}{n}
\DeclareMathSymbol{\boxright} {\mathbin}{bskadd} {"A0}
The problem is that if I need to this more than a handful of times, I will start getting a Latex Error: Too many symbol fonts declared.
.
Partial solution
@David-carlisle 's solution below is attractive in this context, but I'm still not quite getting it to work. The basic definition is something like this:
\makeatletter
\newcommand\NewFontImport[6]{
\newcommand#1{\begingroup\mathchoice%
{\hbox{\fontsize{\tf@size}{\tf@size} \usefont{#2}{#3}{#4}{#5}\char#6}}%
{\hbox{\fontsize{\tf@size}{\tf@size} \usefont{#2}{#3}{#4}{#5}\char#6}}%
{\hbox{\fontsize{\sf@size}{\sf@size} \usefont{#2}{#3}{#4}{#5}\char#6}}%
{\hbox{\fontsize{\ssf@size}{\ssf@size}\usefont{#2}{#3}{#4}{#5}\char#6}}%
\endgroup
}}
\makeatother
This works well for, e.g., boisik \boxright
:
\DeclareFontFamily{U}{bskma}{\skewchar\font130 }
\DeclareFontShape{U}{bskma}{m}{n}{<->bskma10}{}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\NewFontImport\boxright{U}{bskma}{m}{n}{"A0}
(Well, it doesn't because boisik currently has a bug with its sans serif Greek Sigma that only appears at scale mag:=0+420/600
. I sent a bug report to the author. Commenting out sans serif Greek Sigma in the metafont sources works around it.)
Outstanding problems
But it doesn't seem to work across the board.
- It doesn't work for
mathabx
big-operators:
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5> <6> <7> <8> <9> <10>
<10.95> <12> <14.4> <17.28> <20.74> <24.88>
mathx10
}{}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\NewFontImport\bigboxright{U}{mathx}{m}{n}{"D9}
as the \bigboxright
ends up being typeset below the baseline. I think I'm passing the wrong argument to \setfont
, but not sure what I should pass.
- It doesn't work for delimiters:
\DeclareFontFamily{OMX}{MnSymbolE}{}
\DeclareFontFamily{OMX}{MnSymbolA}{}
\DeclareFontShape{OMX}{MnSymbolE}{m}{n}{
<-6> MnSymbolE5
<6-7> MnSymbolE6
<7-8> MnSymbolE7
<8-9> MnSymbolE8
<9-10> MnSymbolE9
<10-12> MnSymbolE10
<12-> MnSymbolE12}{}
\DeclareFontShape{OMX}{MnSymbolE}{b}{n}{
<-6> MnSymbolE-Bold5
<6-7> MnSymbolE-Bold6
<7-8> MnSymbolE-Bold7
<8-9> MnSymbolE-Bold8
<9-10> MnSymbolE-Bold9
<10-12> MnSymbolE-Bold10
<12-> MnSymbolE-Bold12}{}
\NewFontImport{\lsemsym}{OMX}{MnSymbolE}{m}{n}{'102}
\NewFontImport{\rsemsym}{OMX}{MnSymbolE}{m}{n}{'107}
I can use \lsemsym
and \rsemsym
on their own, but I cannot use \open\lsemsym \sum_{i=1}^n a_n \close\rsemsym
as they are typeset inside a textbox, and not as variable sized delimiters.
(Lots of kudos for @David Carlisle for all his patience in getting me this far!)
\Umathchardef
rather than\mathchardef
so going beyond 16.standalone
to create the symbol as a PDF. Then you could import it as an image and usescalerel
package to give it the right math sizing characteristics, as in this answer: tex.stackexchange.com/questions/477182/math-saturation-symbol/…