Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I recently hit up against TeX's "too many math alphabets" error. I'm trying to diagnose what is using up my math alphabets, as I can't work out where they are going. Of course, I could just start commenting out sections, but given that this document is 100 pages long, that could take a long time.

I'd like to know what packages might be loading math alphabets, and what things count as being from different math alphabets.

My document compiles if I replace

\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}%
              {<-> s * [1.2] pzcmi7t}{}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}%
                                 {m}{it}

with

\let\mathpzc\mathcal

but the following compiles without complaint:

\documentclass{article}
\usepackage{kpfonts}
\usepackage{amsmath}
\usepackage[matha]{mathabx}
\DeclareFontFamily{OT1}{pzc}{}
\DeclareFontShape{OT1}{pzc}{m}{it}%
              {<-> s * [1.2] pzcmi7t}{}
\DeclareMathAlphabet{\mathpzc}{OT1}{pzc}%
                                 {m}{it}

\begin{document}
$X \mathbf{X}\mathbb{X}\vDash\mathpzc{X}\alpha\displaystyle\sum \subset \top\mathcal{X}$
\end{document}

This document includes (as far as I can tell) all the kinds of math alphabets I took myself to be using. So I am missing something. Something else is using extra math alphabets and I'm not sure how to work out what. What other things count as being different alphabets? What else loads math alphabets?


Here's something weird. I do this with a version of my main file and I get this:

(0:~jkpmn7t at 12.0pt)
(1:~jkpmi at 12.0pt)
(2:~jkpsy at 12.0pt)
(3:~jkpex at 12.0pt)
(4:~jkpmia at 12.0pt)
(5:~msam10 at 12.0pt)
(6:~msbm10 at 12.0pt)
(7:~jkpsyc at 12.0pt)
(8:~jkpexa at 12.0pt)
(9:~lasy10 at 12.0pt)
(10:~cmex10 at 12.0pt)
(11:~jkpssmn7t at 12.0pt)
(12:~jkpttmn7t at 12.0pt)
(13:~jkpbn7t at 12.0pt)
(14:~jkpsyd at 12.0pt)
(15:~jkpmn7t at 12.0pt)

Note that 0 and 15 appear to be the same font…

Edit

I asked a followup question to this one.

share|improve this question
    
Weirdly, \let\mathcal\mathpzc doesn't seem to work… –  Seamus Jan 11 '12 at 14:59
    
When you load the kpfonts package, the amsmath package is loaded by default -- a setting that can be overridden by loading the package with the noamsmath option set. In order not to load any of kpfonts' own math alphabets, you should specify the option nomath. –  Mico Jan 12 '12 at 13:26
    
@Mico Thanks for that. Although in this case, that's not going to help, since I want amsmath and I do want to use kpfonts math fonts. I'm just trying to work out why there are so many of them! –  Seamus Jan 12 '12 at 13:50
add comment

1 Answer

up vote 11 down vote accepted

Math alphabets are loaded "on demand"; so, your \let\mathpzc\mathcal doesn't cause LaTeX to allocate a new math alphabet, since the meaning assigned with \DeclareMathAlphabet is forgotten (and the math alphabet has not yet been assigned a "math group").

However, once a math alphabet has been used in a formula, its association to a math group is permanent (the actual font will be recomputed based on the current font size).

You can see what math groups are allocated at a particular spot in the document with \PrintMathFonts defined as

\newcommand{\PrintMathFonts}{%
  \count255=0
  \loop\ifnum\count255<16
    (\the\count255:~\fontname\textfont\count255)
    \advance\count255 by 1
 \repeat}

There are only 16 math groups available (the limit is raised by XeTeX and LuaTeX, but one has to change the allocating macros). If I use it immediately after \begin{document} I get

(0: nullfont) (1: nullfont) (2: nullfont) (3: nullfont) (4: nullfont) (5: nullfont) (6: nullfont) (7: nullfont) (8: nullfont) (9: nullfont) (10: nullfont) (11: nullfont) (12: nullfont) (13: nullfont) (14: nullfont) (15: nullfont)

After a trivial formula, $a$, I get

(0: jkpmn7t) (1: jkpmi) (2: jkpsy) (3: jkpex) (4: jkpmia) (5: jkpsya) (6: jkpsyb) (7: jkpsyc) (8: jkpexa) (9: matha10) (10: nullfont) (11: nullfont) (12: nullfont) (13: nullfont) (14: nullfont) (15: nullfont)

After the big formula I get

(0: jkpmn7t) (1: jkpmi) (2: jkpsy) (3: jkpex) (4: jkpmia) (5: jkpsya) (6: jkpsyb) (7: jkpsyc) (8: jkpexa) (9: matha10) (10: jkpbn7t) (11: pzcmi7t at 11.99997pt) (12: nullfont) (13: nullfont) (14: nullfont) (15: nullfont)

If I also add the formula $\mathsf{A}$, I get

(0: jkpmn7t) (1: jkpmi) (2: jkpsy) (3: jkpex) (4: jkpmia) (5: jkpsya) (6: jkpsyb) (7: jkpsyc) (8: jkpexa) (9: matha10) (10: jkpbn7t) (11: pzcmi7t at 11.99997pt) (12: jkpssmn7t) (13: nullfont) (14: nullfont) (15: nullfont)

Note that some math groups are allocated as soon as a formula is typeset, others aren't (they correspond to math alphabets as opposed to math symbol fonts).

So you see that 10 math groups are already allocated, so you are free to use only up to 6 different math alphabets that don't use letters from the symbol fonts already available (look for \DeclareSymbolFontAlphabet in fntguide.pdf).

EDIT

A variant of the code above will show in the log file the list, together with the font's symbolic name:

\newcommand{\PrintMathFonts}{%
  \typeout{*** Math fonts list ***}
  \count255=0
  \loop\ifnum\count255<16
    \typeout{(\the\count255: \the\textfont\count255 = \fontname\textfont\count255)}
    \advance\count255 by 1
  \repeat
  \typeout{***}}

For example, what's printed after the big formula is

*** Math fonts list ***
(0: \OT1/jkp/m/n/10 = jkpmn7t)
(1: \OML/jkp/m/it/10 = jkpmi)
(2: \OMS/jkp/m/n/10 = jkpsy)
(3: \OMX/jkp/m/n/10 = jkpex)
(4: \U/jkpmia/m/it/10 = jkpmia)
(5: \U/jkpsya/m/n/10 = jkpsya)
(6: \U/jkpsyb/m/n/10 = jkpsyb)
(7: \U/jkpsyc/m/n/10 = jkpsyc)
(8: \U/jkpexa/m/n/10 = jkpexa)
(9: \U/matha/m/n/10 = matha10)
(10: \OT1/jkp/b/n/10 = jkpbn7t)
(11: \OT1/pzc/m/it/10 = pzcmi7t at 11.99997pt)
(12: \nullfont = nullfont)
(13: \nullfont = nullfont)
(14: \nullfont = nullfont)
(15: \nullfont = nullfont)
***

There's no "global registry", I'm afraid, so you have to sort out the fonts according to the packages you're using. Look for the commands

\DeclareSymbolFont
\DeclareMathAlphabet

The first command declares a math group that is always allocated; the second one causes the math group to be allocated on demand, as said before. For example, the entry

(10: \OT1/jkp/b/n/10= jkpbn7t)

is caused by \mathbf and in kpfonts.sty you can find a line

\DeclareMathAlphabet{\mathbf}{OT1}{jkp\kp@famillem\kp@fligm\kp@stylem}{b}{n}

that defines it.

share|improve this answer
    
How can I find out what, for example jkpmn7t is and where it is used? –  Seamus Jan 11 '12 at 17:55
    
I use it immediately after \begin{document} I get 13 used already… –  Seamus Jan 11 '12 at 19:03
    
@Seamus Not with that preamble. –  egreg Jan 11 '12 at 20:11
    
No not with that preamble. But I'm confused as to what could cause alphabets to be used up before anything's been written to the file! –  Seamus Jan 11 '12 at 20:49
    
@Seamus It's impossible to tell without seeing a MWE exhibiting the problem. It's highly possible that some definition in the preamble builds a box with math in it, so the math groups for \DeclareSymbolFont are allocated before \begin{document}. In general, they are allocated the first time LaTeX has to build a formula. –  egreg Jan 11 '12 at 21:05
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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