5

I have this "Too many symbol fonts declared" that is different from the two other posts in the forum.

I am writing a book section where I have several subfiles with custom math symbols (from the open source cool jazz font). I can repeat up to 6 subfiles (6 different sections) but for the 7th I get the "too many symbol fonts declared" error and the subfile does not render the math part... Here is my MWE to reproduce the error:

Main.tex file:

%minimal example
\documentclass[11pt,portuguese, twoside,openright]{book}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{enumerate}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}

%setting an environment for hand- solved examples

\newenvironment{coolj}{
    %\defaultfontfeatures{Scale=MatchUppercase}
    \setmonofont{CMU Typewriter Text}[Scale = .90]
    \setmainfont{Cooljazz}[Scale = .85]
    \setmainfont[Ligatures=TeX,BoldFont={Boogaloo Regular},Scale=.90]{Cool jazz}
    \setmathfont[math-style=upright, range={"00-"FF,
        "03C0, "2013-"2014, "2018-"201A, "201C-"201E, "2021-"2022,
        "2026, "2030, "2039-"203A, "2044, "20AC, "20BA, "20BD,
        "2113, "2122, "2126, "212E, "2202, "2206, "2208, "220F, "2211,
        "2212, "2215, "221E, "222B, "2246, "2260, "2264, "2265,
        "25CA, up/{Latin,latin,num,Greek,greek}},Scale=0.85]{cooljazz.ttf}
    \setmathfont[range={"58-"60}]{Latin Modern Math}
}{\par}    

\usepackage{subfiles} % to load independent chapters

\begin{document}

Main doc

%repeating several subfiles with coolj enviroment   
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}

\end{document}

As you can see I am inputting a subfile (here for simplicity always the same, but different files are used in the real scenario):´

ex1.tex:

\documentclass[main.tex]{subfiles}
\usepackage{enumerate}

\begin{document}

Some text...

\begin{coolj}{Example 1}
    
    This is example 1 with text describing the problem
    
\begin{enumerate}
    
    \item Some text
    
    \item Some math with cooljaz.ttf font defined in the main tex doc coolj environment
    \item[] $H^{}_0: \mu_{Baseline}=\mu_{M04}=\mu_{M08}=\mu_{M12} \quad vs.\\H^{M}_1: \exists i, j: \mu_i \neq \mu_j \quad i \neq j; \ i,j=(Baseline,M04, M08, M12)$
    \item[]$H^{M\times G}_0\!:\gamma_{M\times G}\!=\!0  \quad vs. \quad H^{M\times G}_1:\!\gamma_{M\times G}\! \neq\! 0$
    \item [] $S'^2_{\bar Y} \neq \sum_{i=1}^{n}(Y_i- \bar Y)^2$
    
\end{enumerate}

Some more text with free font cooljaz.ttf

\end{coolj}
\vspace{\baselineskip}
back to regular text!...
\end{document}

It works fine with 6 ex1.tex subfiles, but for the 7th it gives this error and does not render correctly:

Too many symbol fonts declared. \begin{coolj}
Symbol font __um_fam13 not defined. \begin{coolj}
\begin{coolj} Missing number, treated as zero. \begin{coolj}

Any idea on how to solve this problem? The full book will have more than 100 examples (I hope...using the cooljazz font. If you want to see the font the link is https://freefontsfamily.com/cool-jazz-font-family-free-download/

Thanks!

12
  • Just out of curiosity: Why is it necessary to state \setmainfont and \setmathfont directives repeatedly? From what you've reported, there would appear to be no need for that.
    – Mico
    Commented Oct 31, 2021 at 9:18
  • 1
    both the text font and the math font in the coolj environment are the handwritten font...If I don't set the mathfont I would not get the greek symbols and math operators in cool jazz
    – JPMD
    Commented Oct 31, 2021 at 9:23
  • 1
    Yes, please do consult section 4.3 of the user guide. (Sorry, but I will not pay $16.50 to a website operator of unknown trustiworthiness for the privilege of downloading a single copy of the Cool Jazz font, no matter how cool this font may be... Hence, I can't really run your code in a realistic manner. All I can do is make -- hopefully useful -- suggestions for what you may do.)
    – Mico
    Commented Oct 31, 2021 at 9:30
  • 1
    "... then all math (outside of the environment) will also be coolj no?" No. What is your main document math font, for use outside coolj environments? Is it Latin Modern Math? If so, just execute \setmathfont[version=Main,...]{Latin Modern Math} and \setmathfont[version=CoolJ,...]{cooljazz.ttf} once in the preamble and switch between the Main and Coolj versions at the start and end of each coolj environment.
    – Mico
    Commented Oct 31, 2021 at 9:46
  • 1
    The problem is at each call of coolj, unicode-math allocates a new math group, but using the legacy allocation mechanism with an upper bound of 16. But even if we raised the upper bound to 256, the problem would still be there: you'd just push the error forward.
    – egreg
    Commented Oct 31, 2021 at 22:10

2 Answers 2

4

This works:

\documentclass[11pt,portuguese, twoside,openright]{book}
\usepackage{fontspec}
\usepackage{enumerate}
\usepackage[math-style=ISO, bold-style=ISO]{unicode-math}
\setmathfont{Latin Modern Math}% default math font
\setmathfont[math-style=upright, range={"00-"FF,
        "03C0, "2013-"2014, "2018-"201A, "201C-"201E, "2021-"2022,
        "2026, "2030, "2039-"203A, "2044, "20AC, "20BA, "20BD,
        "2113, "2122, "2126, "212E, "2202, "2206, "2208, "220F, "2211,
        "2212, "2215, "221E, "222B, "2246, "2260, "2264, "2265,
        "25CA, up/{Latin,latin,num,Greek,greek}},Scale=0.85]{cooljazz.ttf}
\setmathfont[range={"58-"60}]{Latin Modern Math}    
\newfontface\CoolJazz[Scale=0.85,Ligatures=TeX,BoldFont={Boogaloo Regular}]{Cool jazz}
\setmonofont{CMU Typewriter Text}[Scale = .90]

%setting an environment for hand- solved examples

\newenvironment{coolj}
  {\CoolJazz}{\par}    

\usepackage{subfiles} % to load independent chapters

\begin{document}

Main doc

%repeating several subfiles with coolj enviroment   
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}
\subfile{ex1}

\end{document}

If you need another math font for other text then use the optional argument version

12
  • yes, I do need to revert to the latin modern outside of the environment... I played with the \setmathfont[version=Main]{Latin Modern Math} and then mathversion{Main} but I can't reverse the font back to latin modern... can you please show me how in your code?
    – JPMD
    Commented Oct 31, 2021 at 10:14
  • 1
    @JPMD - You could change \newenvironment{coolj}{...}{\par} to \newenvironment{coolj}{...}{\par\mathversion{Main}}.
    – Mico
    Commented Oct 31, 2021 at 11:46
  • @JPMD: you have to define one main math font without the version keyword. But you can define a lot of other ones with different version=... (max 256)
    – user187802
    Commented Oct 31, 2021 at 12:04
  • So, it should be something like this \newenvironment{coolj} {\CoolJazz \mathversion{Coolj} }{\par\mathversion{normal}} ? Does not work. Now all math is latin modern an no cool jazz... Sorry guys, I am lost here...
    – JPMD
    Commented Oct 31, 2021 at 12:52
  • @JPMD: Only \newenvironment{coolj} {\CoolJazz \mathversion{Coolj}}{\par} inside the environment everything is local, after the environment you have the same setting as before.
    – user187802
    Commented Oct 31, 2021 at 13:05
0

for future reference for other people that may want to use handwriting fonts without "Math Tables". This is a solution, copied and adapted as needed from this StackExchange fonts-Create a Handwriting environment that works:

\usepackage[no-math]{fontspec}
%\usepackage{amsmath}
\usepackage{mathtools}
%\usepackage{siunitx}

\newfontfamily\cooljazz[NFSSFamily=cooljazz]{cooljazz}
\usepackage[subdued, defaultmathsizes]{mathastext}
\MTfamily{cooljazz}
\Mathastext[cooljazz]

\newenvironment{coolj}{\MTversion{cooljazz}\MTdonotfixfonts
    \setmainfont{cooljazz}[Scale = .5, Extension = .ttf ]
    % adjust some additional glyphs
    \Umathchardef\prod 1 \symmtoperatorfont `∏\relax % mathop
    \Umathchardef\sum  1 \symmtoperatorfont `∑\relax % mathop
    \Umathchardef\in   3 \symmtoperatorfont `∈\relax %
    \Umathchardef\int  1 \symmtoperatorfont `∫\relax % mathop
    \Umathchardef\neq  3 \symmtoperatorfont `≠\relax % mathrel
    %\Umathchardef\sqrt  1 \symmtoperatorfont `√\relax % mathrel
    \Umathchardef\mu  1 \symmtoperatorfont `μ\relax % greek
    \Umathchardef\sigma 1 \symmtoperatorfont `σ\relax % greek
    \Umathchardef\gamma 1 \symmtoperatorfont `γ\relax % greek
    \Umathchardef\beta 1 \symmtoperatorfont `β\relax % greek
    \Umathchardef\epsilon 1 \symmtoperatorfont `ε\relax % greek
    \Umathchardef\eta 1 \symmtoperatorfont `η\relax % greek
    \Umathchardef\alpha 1 \symmtoperatorfont `α\relax % greek
    \Umathchardef\theta 1 \symmtoperatorfont `θ\relax % greek
    \Umathchardef\rho 1 \symmtoperatorfont `ρ\relax % greek
    \Umathchardef\phi 1 \symmtoperatorfont `ϕ\relax % greek
    \Umathchardef\sim 1 \symmtoperatorfont `~\relax % greek
    \Umathchardef\exists 1 \symmtoperatorfont `∃\relax % greek
    %
}{\par}
 

\usepackage{subfiles} % to load independent chapters

\begin{document}
    
    Main doc
    
    %repeating several subfiles with coolj enviroment   
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    \subfile{ex1}
    
\end{document} 

You will need the ex1.tex file in the beginning of this (long) trend.

There are still some minor glitches (e.g. the \sqrt overline does not extend over the all expression) and it is a little work to get all the greek symbols and math operators, but...

Learning on how to do add a math table for a given font would be the way to go, but that requires time and skills (and I lack both :-))

Thank you all for the input suggestions and explanations! You guys rock!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .