Skip to content

Instantly share code, notes, and snippets.

@dorchard
Last active March 26, 2025 09:32
Show Gist options
  • Select an option

  • Save dorchard/e846a8382d8fc98b08ac9acacfd71f85 to your computer and use it in GitHub Desktop.

Select an option

Save dorchard/e846a8382d8fc98b08ac9acacfd71f85 to your computer and use it in GitHub Desktop.
Dealing with Ott "! LaTeX Error: Too many math alphabets used in version normal."

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 to xelatex which 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 where l does not occur in the production (which is just Foo). 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment