Whilst using the Ott tool for defining programming languages and semantics (http://www.cl.cam.ac.uk/~pes20/ott/) I have noticed that I sometimes get the following error when compiling its generated LaTeX:
! LaTeX Error: Too many math alphabets used in version normal.
This is a difficult to track down error (but also mildly amusing)! Here are the solutions/reasons I've found so far:
-
Using
pdflatex? Try switching toxelatexwhich can support up 256 math fonts. -
This error seems to pop up if you have custom TeX for a grammar production which has an embedded Ott fragment using a free variable that is not in bound in the production. For example:
| Foo :: :: ExampleRule {{com An example grammar production }} {{tex \mathsf{Foo} {[[l]]} }}Notice the Ott fragment
[[l]]in the custom TeX whereldoes not occur in the production (which is justFoo). Fixing this removes the "too many math alphabets" problem, so check your productions for this problem. -
Sometimes not having any custom TeX can trigger this error in a production, e.g.,
| Foo l :: :: ExampleRule {{com An example parametric grammar production }}So the solution here seems to be to add a custom TeX attribute to the end like in the example from the previous point.
-
If the above doesn't appear to be an issue then I've found that including the following line early in the preamble of the embedding LaTeX document can solve the issue:
\newcommand\hmmax{0}
See this StackExchange thread which relates to this problem more generally which might provide some additional context/ideas (for example \newcommand\bmmax{0} is also suggested). See also this: https://texfaq.org/FAQ-manymathalph