重复自定义数学环境时出现“声明的符号字体过多”错误

重复自定义数学环境时出现“声明的符号字体过多”错误

我有这个“声明了太多的符号字体”,这与论坛中的其他两个帖子不同。

我正在编写一个书的部分,其中有几个带有自定义数学符号的子文件(来自开源酷爵士字体)。我可以重复最多 6 个子文件(6 个不同的部分),但对于第 7 个,我收到“声明了太多符号字体”错误,并且子文件不会呈现数学部分...这是我的 MWE 重现错误:

Main.tex 文件:

%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}

正如您所见,我正在输入一个子文件(这里为了简单起见总是相同的,但在实际情况下使用不同的文件):'

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}

它可以很好地处理 6 个 ex1.tex 子文件,但对于第 7 个子文件,它会出现此错误并且无法正确呈现:

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

有解决这个问题的主意吗?整本书将有 100 多个示例(我希望……使用 cooljazz 字体。如果您想查看字体,链接是https://freefontsfamily.com/cool-jazz-font-family-free-download/

谢谢!

答案1

这有效:

\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}

如果您需要其他文本的另一种数学字体,请使用可选参数version

答案2

供其他可能想要使用没有“数学表”的手写字体的人将来参考。这是一个解决方案,根据需要从此 StackExchange 复制并改编字体-创建手写环境这样可行:

\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} 

您将需要在该(长期)趋势开始时使用 ex1.tex 文件。

仍然存在一些小问题(例如\sqrt上划线没有延伸到所有表达式)并且获取所有希腊符号和数学运算符需要一点工作,但是......

学习如何为给定的字体添加数学表是可行的方法,但这需要时间和技能(而我两者都缺乏:-))

感谢大家提供的建议和解释!你们太棒了!

相关内容