4

I have been using xelatex plus unicode-math for too long, and I forgot how to use pdflatex. As far as I heard, the STIX fonts are proposed as a free replacement of the fonts of Times family. They have a variety of styles and a large number of symbols. However, I recurrently fall in the same trap, namely, I do not know how to call different styles properly.

  • Just today I've asked how to access the bold calligraphic style and got this excellent answer. I thought my problems were over, but then I discovered that \mathbfit as well as \bm does not produce bold slanted greek letters. I remember, I have see the solution already. There are also a lot of discussion here for different fonts.

  • I found that last year I had a similar problem with STIX, and indeed got many useful answers. But then again, after re-reading the probably expert answer of Davislor I understood that I do not understand anything. Why it has to be sooooo difficult to make lambda bold!? Why, as a user, not developer I have to worry about the font ranges, fake bolds and isomath?

But I would like to narrow my question as much as possible in order to get a comprehensive answer. I would like to know how to access all possible 17 styles of math stix fonts and how this syntax is different from accessing all possible 9 styles of cm fonts. Furthermore, I am interested only in the pdflatex compatible answer. No font substitution is allowed.

Below is my minimal non working example

\documentclass[]{article}
\usepackage{stix}
\usepackage{amssymb,amsmath}
\newcommand{\symb}{aA\psi\Psi12}
\begin{document}
\begin{align}
%\mathup{\symb}\\
%\mathbfup{\symb}\\
\mathit{\symb}\\
\mathbfit{\symb}\\
%\mathsfup{\symb}\\
\mathsfit{\symb}\\
%\mathbfsfup{\symb}\\
\mathbfsfit{\symb}\\
\mathtt{\symb}\\
\mathbb{\symb}\\
\mathbbit{\symb}\\
\mathscr{\symb}\\
\mathbfscr{\symb}\\
\mathcal{\symb}\\
\mathbfcal{\symb}\\
\mathfrak{\symb}\\
\mathbffrak{\symb}
\end{align}
\end{document}

It gives me a strange error

! LaTeX Error: Too many math alphabets used in version normal.

Summary for making it a bountied question

  1. My ultimate goal is to make as many as possible commands presented above to work in one document in a predictive fashion.

  2. Naturally, no one will ever need to have all the styles in one document. So the error quoted above is not essential. But a reasonable subset of styles would be nice. An example would be in addition to regular variables, vectors (bold-italic, possibly calligraphic), matrices, tensors (bold serifless and sometimes calligraphic), sets (mathbb), codes (mathtt).

  3. I would like an explanation why in order to use \mathbfcal (not even in the alphabet table) DeclareMathAlphabet is needed, whereas in order to use \mathbfit{\psi} for greek letters the option lcgreekalpha is needed. Especially for the latter, I was assuming that a font selection command is a low level command, unlike for instance \emph, which takes other considerations into account. But why then one needs lcgreekalpha to overwrite.

yarchik
  • 272
  • 1
    as in your last question Package amssymb Warning: The 'amssymb' package is redundant when you are using the 'stix' package, so I'm not going to load amssymb. You can/should remove amssymb (it doesn't fix the problem but a cleaner log helps debugging issues) – David Carlisle Jan 28 '21 at 23:20
  • 2
    xelatex allows 256 math fonts and each of those can cover the entire Unicode range of tens of thousands of characters. Then you switch to pdflatex and that allows 16 math fonts each has at most 256 characters. Something has to give..... – David Carlisle Jan 28 '21 at 23:33
  • the lcgreekalpha is simply a design choice. no one other than the package designer can really say "why". Classically in tex \alpha uses a fixed font and is not affected by math alphabet commands. stix.sty chooses to keep to that behaviour, but offers the option to have a behaviour more like unicode-math where \alpha works like a and does follow the math alphabets. – David Carlisle Feb 01 '21 at 20:14
  • @DavidCarlisle Because bold italic greeks are super dangerous, one needs a trigger guard in the form of cgreekalpha. – yarchik Feb 01 '21 at 20:22
  • no probably to minimise the changes that happen if you add \usepackage{stix} to an existing document. but it's impossible to say why (unless you are the author of the package) the package could have been defined not to have the option or to make the option default the other way, but they chose to do it the way they did. I gather you didn't like my answer as you ask for another but I don't know what else could be said. Still someone might answer. – David Carlisle Feb 01 '21 at 20:25
  • @DavidCarlisle I like that you try to be rigorous by referring to the documentation. But without even a minimal example I cannot point out to the defects in solution nor ask for the refinement. In other words, your solution is a priori veridical. Instead, I would like something that can be verified by compiling. – yarchik Feb 01 '21 at 20:33
  • actually I don't understand. You provided a perfectly good example in your question that tries to load multiple alphabets and errors. My answer does not provide or suggest any code, it simply says that that is the expected and documented behaviour, you can't have that many math alphabets. Sorry if that isn't the answer you wanted but I'm just the messenger don't blame me:-) – David Carlisle Feb 01 '21 at 20:36
  • but sorry I didn't mean to argue. Just because I can not think of a way of rephrasing my answer doesn't mean that someone else can not do so. Hopefully the bounty will encourage someone to try. – David Carlisle Feb 01 '21 at 20:39
  • @DavidCarlisle Probably I need to formulate the question better. I was expecting some usage examples. You mention 16 as a hard limit and 12 is mentioned in the documentation. Well, I tell you honestly, my record for a single document is unreasonably low, maybe 4 or 5 fonts. At the moment I am writing a mathematical paper where I need to add a code listing. And I cannot do it because all fonts are already used. What is your record? – yarchik Feb 01 '21 at 20:46
  • 16 is the limit in tex (for a single math expression), 12 refers to the available math alphabet slots after 4 symbol fonts have been defined. (code listings are usually set as text, you are using math fonts??) – David Carlisle Feb 01 '21 at 20:49
  • Is mathtt frowned upon, like comic sans? "12 refers to the available math alphabet slots after 4 symbol fonts have been defined" can you please substantiate your statement? I would be extremely happy to have 12 fully functional math styles in one document! It seems that one part of my misunderstanding stems from the fact that I do not know the difference between the math alphabets and symbol fonts. I thought they are all the same STIX in both cases. That is why I prefer to call them styles. – yarchik Feb 01 '21 at 21:15
  • 1
    as I mentioned in my answer latex has symbol fonts \DeclareSymbolFont{...}... which are allocated at the point of declaration, this is used for things like \sum or \rightarrow or \langle etc these need a known slot to work with \mathchardef an math alphabets declared with \DeclareMathAlphabet these are only allocated if used so you can declare as many as you like but can only use at most 16 minus however many symbol fonts are declared. – David Carlisle Feb 01 '21 at 21:19
  • I am not sure what you mean by "same stix" the stix package sets up 47 fonts for pdftex /usr/local/texlive/2020/texmf-dist/fonts/tfm/public/stix/ has 47 tfm files. – David Carlisle Feb 01 '21 at 21:23
  • why your question about \mathtt that is defined by default by the stix package. – David Carlisle Feb 01 '21 at 21:25
  • "happy to see 12 functional math styles" ??? your example shows 12 if you comment out the 13th: – David Carlisle Feb 01 '21 at 22:32

1 Answers1

9

latex math alphabets (unlike math symbol fonts) are assigned on demand as they are used. This means that you can declare any number of math alphabets but you may only use a total of 16 math fonts (math symbol fonts and math alphabets). This 16 is a hard limit of the TeX program.

Apart from test documents that are trying to use every possible font in a single document it is highly unusual to need that many alphabets. So I am tempted to say that this is a feature.

If you really need to access that many fonts you can (with some constraints) declare the fonts as text fonts or (possibly better) declare different math versions (cf normal and bold math versions) and arrange that different subsets of the fonts are available in each version with no more than 16 in each.

That said the stix documentation answers your question and shows all the available math alphabet commands It also warns you that you can not use them all at once.

enter image description here

It is probably advisable to use the stix2 package (based on Stix Two Math font) but the commands are essentially the same and its documentation has essentially the same table.

enter image description here


Note that the hard limit of 16 math fonts is per version not per document, in your original example you have to comment out 3 math alphabet commands to keep below the limit but you can declare another math version with the same initial declarations but in which you use a different set of 16 so I could uncomment the final three math alphabets as long as I comment out some others.

enter image description here

\documentclass[]{article}
\DeclareMathVersion{normal2}
\usepackage{amsmath}
\usepackage[lcgreekalpha]{stix}
\DeclareMathAlphabet\mathbfcal{LS2}{stixcal}{b}{n}
\newcommand{\symb}{aA\psi\Psi12}
\begin{document}
\begin{align}
\mathrm{\symb}\\
\mathbf{\symb}\\
\mathit{\symb}\\
\mathbfit{\symb}\\
\mathsfit{\symb}\\
\mathbfsfit{\symb}\\
\mathtt{\symb}\\
\mathbb{\symb}\\
\mathbbit{\symb}\\
\mathscr{\symb}\\
\mathbfscr{\symb}\\
\mathcal{\symb}\\
\mathbfcal{\symb}\\
\mathfrak{\symb}\\
%\mathsf{\symb}\\
%\mathbfsf{\symb}\\
%\mathbffrak{\symb}
\end{align}

\mathversion{normal2} \begin{align} \mathrm{\symb}\ \mathbf{\symb}\ \mathit{\symb}\ \mathbfit{\symb}\ \mathsfit{\symb}\ \mathbfsfit{\symb}\ \mathtt{\symb}\ \mathbb{\symb}\ \mathbbit{\symb}\ \mathscr{\symb}\ %\mathbfscr{\symb}\ \mathcal{\symb}\ %\mathbfcal{\symb}\ %\mathfrak{\symb}\ \mathsf{\symb}\ \mathbfsf{\symb}\ \mathbffrak{\symb} \end{align}

\end{document}

Note that some alphabets are not complete eg Fraktur doesn't have Greek not surprisingly so you get nonsense if switching to Fraktur for the Greek. Without the lcgreekalpha option the lowe case greek stays unstyled, but stays Greek:

enter image description here

David Carlisle
  • 757,742
  • 1
    My ultimate goal is not to simultaneously access all possible font variations. As you can see, I even commented some rare ones, only 13 are left. But I would like to have a good reference how to call them when needed. – yarchik Jan 28 '21 at 23:37
  • @yarchik you can not have 13 math alphabets there are already 4 or 5 symbol fonts allocated. any font used for a symbol font used to define a symbol like say \rightarrow has to be pre-allocated because the underlying \mathchardef command needs to know the slot number of the allocated font. – David Carlisle Jan 28 '21 at 23:39
  • @yarchik a good reference for the available commands would be texdoc stix page 3 which lists the available math alphabets and the ranges they cover. (note by the way there is a stix2 package for the stix2 fonts as well these days but the commands are essentially identical and the same table is on page 4 of texdoc stix2) – David Carlisle Jan 28 '21 at 23:46
  • I see, however, \mathbfit{\psi} does not produce the desired symbol even though according to the document it is in the available range. Maybe there are more cases, but I have just tested this one. – yarchik Jan 28 '21 at 23:54
  • @yarchik \usepackage[lcgreekalpha]{stix} so the greek follows the alphabets (but then you use up even more slots) see section 2.1 of the manual. – David Carlisle Jan 29 '21 at 00:08
  • "It is probably advisable to use the stix2 package but the commands are essentially the same ", but why, what's the use of such info? 2) In order to use \mathbfcal (not even in the table) DeclareMathAlphabet is needed, in order to use \mathbfit{\psi} for greek letters the option lcgreekalpha is needed, not consistent at all! 3) I can only access 6 (!) styles in one document, but there are vectors (bold-italic, possibly calligraphic), matrices, tensors (bold serifless and sometimes calligraphic), sets (mathbb), codes (mathtt), that is already > permitted.
  • – yarchik Jan 29 '21 at 08:25
  • @yarchik the font encodings designed for stix (LS1 and LS2) are the same and the thousands of commands referencing specific symbols are the same (and the same as unicode-math) and generally the stix2 fonts are an improvement overs stix1 (from xetex or pdftex) I haven't done a side by side comparison of all the differences in the packages for some years but still it seems like generally useful info for most readers (who should use stix2 unless they have specific compatibility reasons to use stix1) – David Carlisle Jan 29 '21 at 08:37
  • Clear and wonderful explanation... – MadyYuvi Mar 18 '22 at 07:32