5

My question is related to: "Too many math alphabets" error but I think it is sufficiently different that it warrants a new thread.

Suppose two things:

  1. In my preamble, I have already done a great deal of work to setup the "normal" mathversion in various ways.

  2. Also, in my preamble, I have written: \DeclareMathVersion{normal2}

Here's my issue: In the main body of the LaTeX document, I want to do the following:

\mathversion{normal}
\input chapter1.tex
\input chapter2.tex
\input chapter3.tex
\input chapter4.tex
\input chapter5.tex
\input chapter6.tex
\input chapter7.tex
\input chapter8.tex
\input chapter9.tex

(It is actually much more than 9 chapters. I have approximately 200 chapters, which constitute more than 5000 pages of mathematics, for the collected papers of a colleague.)

Unfortunately, let's say that chapter 3 requires several math fonts. (Also suppose that a few of the other chapters require a few math fonts of their own too... but chapter 3 requires the most math fonts.) We know that the limit on the number of math fonts in LaTeX is 16. So if chapter 3 uses quite a few fonts, then I might run out of space for math fonts in other chapters. For instance, by the time I get down to (say) chapters 4, 5, 6, etc., I get this dreaded error:

"Too many math alphabets used in version normal."

I read this thread many times in recent days (as well as many other related threads):

"Too many math alphabets" error

In Lars Hellström's reply, Lars says:

"We were able to solve the issue by declaring a separate math version for one of the more alphabet-hungry papers. Concretely, we put the command \DeclareMathVersion{normal2} at the end of the preamble, and the commands \mathversion{normal2} and \mathversion{normal} just before and after respectively the \include for the alphabet-hungry paper."

So I gave a try to the advice from Lars, as follows:

\mathversion{normal}
\input chapter1.tex
\input chapter2.tex
\mathversion{normal2}
\input chapter3.tex
\mathversion{normal}
\input chapter4.tex
\input chapter5.tex
\input chapter6.tex
\input chapter7.tex
\input chapter8.tex
\input chapter9.tex

Lars said: "One thing this trick relies upon is that new math versions are created with all settings of the old one in place, so all declarations previously made for math version normal will be in place also in math version normal2 (and normal3, and so on, if one needs to repeat the trick)."

but I do not see this happening. When I run pdflatex, I do not see all of the good attributes from \mathversion{normal} to be taking effect in chapter 3. For instance, the math font for the symbols, which works great with the "normal" math version in chapters 1 and 2, as well as chapters 4, 5, 6, ...., BUT the attributes are messed up in chapter 3.

I am pretty desperate to figure this out.

I am wondering (for instance) if I can fully copy the attributes of "normal" into "normal2", and then modify (only) the "normal2" within chapter 3 (without changing "normal"). That way, when I get to chapters 4, 5, 6, .... , I will be back to my regular "normal" math font settings.

Is this possible? I basically want to copy all of the properties from "normal" into "normal2", so that I may use "normal2" for (only) chapter 3 (without modifying "normal" at all), and then finally come back to using "normal" again for chapters 4, 5, 6, ....

Thank you very much for considering my questions!

Please note: I do not want to move to XeTeX or LuaTeX because I have been working on these Collected Papers for many years, and I am nearing the end of the long process. I can make each individual chapter work on its own, but when I try to wrap all of the chapters into one document, the chapters that are using a lot of math fonts (like chapter 3 here) are preventing me from effectively moving onwards to the rest of the document (e.g., to chapters 8 and 9) and to simultaneously keep the nice properties from the "normal" math font throughout.

Here is a full Minimal Working Example:

\documentclass[letterpaper,12pt]{article}
\usepackage[margin=1in,vmargin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{mathrsfs}
\usepackage{yfonts}
\usepackage{txfonts}
\usepackage[mathscr]{euscript}
\usepackage{mathtime}

\DeclareMathVersion{normal2}

\begin{document}

%% CHAPTER 1
Ch~1: My favorite fonts are $\mathrm{A} + (\mathfrak{B} + \mathcal{C}) = \mathscr{D}$.

\vskip 24pt
%% CHAPTER 2
Ch~2: I also like bold faced types like $\mathbb{BBB}$.
Here is an interesting math equation:

$(\mathnormal{E} + \textfrak{F}) + \textswab{G} + \textgoth{H} = \varmathbb{I}$

\vskip 24pt
\mathversion{normal2}
%% CHAPTER 3

Ch~3: We can try some more font math.  This Chapter is using mathversion ``normal2''.

PROBLEM \#1:  This equation is strange, because the left-and-right
parens appear as triangles, and the equal sign appears as a script D:

$(\mathsf{J} + \mathtt{K}) = \mathit{L}$

PROBLEM \#2:  Also, the following equation, which worked in Ch.~2, does not
work anymore!

$(\mathnormal{E} + \textfrak{F}) + \textswab{G} + \textgoth{H} = \varmathbb{I}$
\mathversion{normal}

\vskip 24pt
Ch~4: Now I am ready to move onwards with more math.  For instance,
the math parentheses and equal sign work again,
because this chapter uses mathversion ``normal'' again.
$(\mathbf{Q} + \mathbf{R}) = \mathbf{S}$

Fortunately, the equation from Ch.~2 works again:
$(\mathnormal{E} + \textfrak{F}) + \textswab{G} + \textgoth{H} = \varmathbb{I}$


\end{document}
egreg
  • 1,121,712
mdw
  • 145
  • 3
    I am embarrassed that this is my first question on StackExchange, despite having using LaTeX for perhaps 20 years! I usually am able to figure things out myself, and I have many friends who use LaTeX (including Don Knuth himself), but I finally got stumped by this one. I guess I am a bit fatigued, and I guess it is rare to manage such a large project in LaTeX. Many thanks (in advance) for any gentle help that can be offered here. – mdw Jun 27 '19 at 09:06
  • 3
    Could you make an small example that shows which symbol is messed up by the mathversion change? – Ulrike Fischer Jun 27 '19 at 09:24
  • @UlrikeFischer thanks for asking! I was going to make an MWE but I didn't know how to easily wrap this problem into an MWE. The problem only happens as we gradually add the fonts across the chapters, so an MWE would be hard. To your question: Some of the "operators" are not appearing correctly. E.g., the left and right parentheses are not appearing correctly in Chapter 3, because of some other symbol re-assignments that happened in mathversion "normal". (They are getting replaced by triangles.) Similarly, the equal sign is getting replaced by a script letter D in chapter 3. Etc., etc.! – mdw Jun 27 '19 at 09:33
  • 1
    I don't think that creating a MWE is hard: You only need to grab math declarations and some math uses. But it is very hard to answer your question without such a MWE. – Ulrike Fischer Jun 27 '19 at 09:58
  • @UlrikeFischer I appreciate your discussion with me. Thank you. I think my question can be phrased differently, since this is a new topic for me. Question: Is it possible to copy all of the attributes from one mathversion to another mathversion (e.g., from normal to normal2)? I want to work for a short time in normal2, without modifying anything from normal. Do you catch my meaning? I do not know enough about mathversions to know how to copy the attributes from one mathversion to another mathversion, and I do not know if they are copied by reference or by value, if I speak like C, ha! – mdw Jun 27 '19 at 10:19
  • 2
    Sorry but I even don't know what you mean by "attributes". That's why I asked for an example. – Ulrike Fischer Jun 27 '19 at 10:21
  • StackExchange is urging me to move the discuss with @UlrikeFischer to a chat. (Other comments are still welcome!) – mdw Jun 27 '19 at 12:05
  • I added a succinct and descriptive Minimal Working Example. Comments/suggestions are welcome, please! – mdw Jun 27 '19 at 14:43
  • 1
    is it possible to do the MWE without the use of commercial fonts others might not have access to? – daleif Jun 27 '19 at 14:50
  • @daleif Thank you for chiming in. These Collected Papers are to be published in mathtime, and I believe that mathtime has a role in causing the difficulty (maybe?). If I remove the mathtime line, then (I think) things work more properly. I figured that there are sufficiently many mathtime users that this would (hopefully) not be a huge difficulty. – mdw Jun 27 '19 at 14:55
  • Perhaps, for instance, I might need to use mathtime to adjust mathversion "normal2" in some way, but I do not know how. I tried to make my example as simple as possible. – mdw Jun 27 '19 at 14:57
  • 1
    @mdw It’s a great question! – Davislor Jun 27 '19 at 16:05

1 Answers1

7

This is a problem specific to mathtime. Normally a new math version is "initialised with the defaults for all symbol fonts and math alphabets declared so far". But mathtime doesn't use \DeclareSymbolFont to declare its fonts, but \SetSymbolFont and so the new math version gets the original defaults. You will have to reset the math fonts for the new version:

\documentclass[letterpaper,12pt]{article}
\usepackage[margin=1in,vmargin=1in]{geometry}
\usepackage{amsmath,amssymb}
\usepackage{mathtime}

\DeclareMathVersion{normal2}

\makeatletter %needed: (we are setting the symbol font for normal2 here:)
\SetSymbolFont{operators}   {normal2}{\operator@encoding}{ptm}{m}{n}
\SetSymbolFont{letters}     {normal2}{MY1}{mtt}{m}{it}
\SetSymbolFont{symbols}     {normal2}{MY2}{mtt}{m}{n}
\SetSymbolFont{largesymbols}{normal2}{MY3}{mtt}{m}{n}
\makeatother

\begin{document}
$(a=b)$
\mathversion{normal2}
$(a=b)$
\end{document}
mdw
  • 145
Ulrike Fischer
  • 327,261
  • I implemented this fix last night, and it worked excellently on the full 5000 pages of the document. Thank you! I made a new mathversion for each chapter, and I did what you suggested. I even went a little further than that: I copied several relevant lines from the mathtime.dtx so that the lines to declare the mathversion and to SetSymbolFont are even a little more comprehensive. Thank you again! – mdw Jun 28 '19 at 21:15
  • 1
    @Raaja thank you for the suggestion. Done! – mdw Jul 02 '19 at 07:03
  • 1
    @mdw thanks for the consideration :) – Raaja_is_at_topanswers.xyz Jul 02 '19 at 07:06
  • I am curious how to also reset the \mathcal fonts so that they work properly! In the mathversion "normal2" the \mathcal font is showing up in bold, but I do not want it to be bold. – mdw Nov 24 '19 at 18:38
  • This technique has been working great, since we had the discussion in late June / early July.... but today I noticed that whenever I use the \mathcal font in mathversion "normal2", the \mathcal symbols unfortunately show up in bold. I do not know how to make the \mathcal symbols show up in regular (not bold!) format. – mdw Nov 24 '19 at 18:40
  • I modified two lines of the MWE posted above, so that the document body now looks like this: \begin{document} $(a=b)$ $\mathcal{ABC}$ \mathversion{normal2} $(a=b)$ $\mathcal{ABC}$ \end{document} – mdw Nov 24 '19 at 18:41
  • @Ulrike Fischer I am assuming that you know how to solve this problem, since you were so helpful when I posted this during the midsummer! I would welcome your feedback about this, please, if you are willing and able to assist. – mdw Nov 24 '19 at 18:56
  • 1
    @mdw Please edit your original question or perhaps better ask a new one, but do not edit answers to point out problems with the solution. – siracusa Nov 24 '19 at 18:57
  • @siracusa thank you for the tip! I will make a new post. – mdw Nov 24 '19 at 19:02
  • OK thank you very much @siracusa I made a new post here: https://tex.stackexchange.com/questions/517848/ – mdw Nov 24 '19 at 19:14