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!

JPMD
  • 311
  • 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 Oct 31 '21 at 09: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 Oct 31 '21 at 09:23
  • Have you consulted Section 4.3, Maths 'versions', of the user guide of the unicode-math package? It mentions that "[setting a math version] is useful because it is more efficient than loading a complete maths font from scratch every time—especially with thousands of glyphs in the case of Unicode maths!" Hence, you may be better off setting up a mathversion called, say, "CoolJ" once, and then executing \mathversion{CoolJ} rather than \setmathfont at the start of each coolj environment. – Mico Oct 31 '21 at 09:25
  • Thanks! and how to I set a mathversion? I will look at the manual. – JPMD Oct 31 '21 at 09:28
  • 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 Oct 31 '21 at 09:30
  • reading the manual, p. 9, it seems that I need to do \setmathfont[version=Coolj, ... but I am not seeing how to evoke this in the cool j environment. If I define the mathfont outside the environment, then all math (outside of the environment) will also be coolj no? – JPMD Oct 31 '21 at 09:35
  • 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 Oct 31 '21 at 09:46
  • The cool jazz font is freeware (the font is made by Samsung for their Smartphones...). Sorry if I sent you to a paid site. Please see this one https://freefontsfamily.com/cool-jazz-font-family-free-download/ – JPMD Oct 31 '21 at 09: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 Oct 31 '21 at 22:10
  • Yes @egreg... the problem is that the version and range do not work together... If I delete the range=...that I can activate the coolj mathversion and the main (latin modern) mathversion as @Mico suggested. The problem is that for the cooljazz font that does not have a Math declaration, I need to set the greek letters and symbol with range.... – JPMD Oct 31 '21 at 22:19
  • not directky relatex but never use \usepackage[T1]{fontenc} with luatex or xetex, – David Carlisle Oct 31 '21 at 23:15
  • I used to, but I don't use anymore... but it worked or I never run into problems ... @David, do you know if the developers of the unicode-math package have worked on the imcompatibility of version and range? – JPMD Oct 31 '21 at 23:18

2 Answers2

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

user187802
  • 16,850
  • 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 Oct 31 '21 at 10:14
  • 1
    @JPMD - You could change \newenvironment{coolj}{...}{\par} to \newenvironment{coolj}{...}{\par\mathversion{Main}}. – Mico Oct 31 '21 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 Oct 31 '21 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 Oct 31 '21 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 Oct 31 '21 at 13:05
  • @user187802: can you please modify your answer above to get back the default font? I am afraid that version and range do not get along. If I do \newenvironment{coolj} {\CoolJazz \mathversion{Coolj}}{\par} all formulas get the cool jazz font. If I do \newenvironment{coolj} {\CoolJazz \mathversion{Coolj}}{\par \mathversion{normal}} I should get the latin modern after ... but I don't.... – JPMD Oct 31 '21 at 13:33
  • So, yes version and range do not work together.... The unicode_math manual actually warns about that (p. 10: "Note there are currently open issues regarding the interaction between the version and the range features, so please proceed with caution." ... :-( Any other ideas? – JPMD Oct 31 '21 at 15:14
  • Modify your example, then I can see, what you mean... – user187802 Oct 31 '21 at 16:26
  • if you remove the range=...then the \setmathversion{Main} works!... – JPMD Oct 31 '21 at 19:51
  • @Mico have you come with some other ideas on how to solve this? since version and range do not work.... :-( – JPMD Dec 13 '21 at 15:53
  • @JPMD - Please clarify your "do not work" comment. Are you saying that my suggestion, "You could change\newenvironment{coolj}{...}{\par} to \newenvironment{coolj}{...}{\par\mathversion{Main}}" isn't producing the expected result? Do you get warning and/or error messages? Please be specific, as my psychic divination skills are -- sadly, but maybe not surprisingly -- absolutely worthless. – Mico Dec 13 '21 at 17:52
  • Hi @Mico. Yes, the range and version from unicode-math do not work together. The manual, p.10 gives the warning about that incompatibility. The file does compile with LuaLaTex but the effect is not the expected one, that is, the math font does not revert to the font declared in the version=Main. – JPMD Dec 13 '21 at 18:00
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!

JPMD
  • 311