12.3 Traditional math font setup through packages
Implementing a setup for math in LaTEX is a rather complicated undertaking and not something you do in a preamble of your document. There you might add a few declarations for math alphabets with or through the packages discussed in Section 12.1 or define your own notations as we have done in several examples throughout the book.
However, if you want to replace all glyphs used in formulas with new ones that have a different design, you typically simply call one or more packages that do the hard work for you behind the scenes. In this section we discuss a number of them. As mentioned earlier, most of them can be used with every TEX engine even if they are based on 8-bit fonts.2 Setting up math using Unicode fonts (and thus usable only with Unicode engines) is the subject of Section 12.4.
12.3.1 ccfonts — The Concrete fonts for text and math
Starting from the work done for the EC fonts, it was relatively easy to create Concrete Roman fonts in T1 and TS1 encodings (original work by Frank Mittelbach; current version by Walter Schmidt (1960–2021)). Ulrik Vieth used the construction method outlined by Knuth [94] to develop a companion set of Concrete Math fonts including the full range of AMS symbols (as provided by the amssymb or amsfonts package).
The first package that provided access to these font families for normal text was beton (by Frank Jensen). A more recent development that also provides the use of Concrete fonts for math and supports the T1 and TS1 encodings is the ccfonts package by Walter Schmidt; see page 65 for details.
Because the Concrete fonts have no boldface series, the ccfonts package offers the option boldsans to use the semibold series of the Computer Modern Sans fonts as a replacement. As a result, without any further adjustments, headings in standard classes are typeset using this font series. A larger sample page is shown in Figure 12.39 on page 288.
12.3.2 cmbright — The Computer Modern Bright fonts
Another font family whose design is based on the METAFONT sources of the CM fonts are the Computer Modern Bright (CM Bright) fonts by Walter Schmidt (1960– 2021), shown in Table 10.3 on page 12. This family of sans serif fonts is designed to serve as a legible body font. It comes with matching typewriter and math fonts, including the American Mathematical Society symbols.
Loading the cmbright package in the preamble ensures that these families are selected throughout the document. It is recommended that you combine this package with fontenc, as shown in the next example, to achieve proper hyphenation with languages other than English. All CM Bright fonts have fully implemented T1 and TS1 encoding support.
12.3.3 euler, eulervm — Accessing Zapf’s Euler fonts
As mentioned earlier, Hermann Zapf (1918–2015) designed a beautiful set of fonts for typesetting mathematics — upright characters with a handwritten flavor — named after the famous mathematician Leonhard Euler [100]. These fonts can be accessed as (math) alphabets of their own, or you can generally modify the math font setup, thus making LaTEX use Euler math fonts (rather than Computer Modern) by default.
The Euler fonts contain three math alphabets: SCRIPT, Euler Fraktur, and Euler Roman.1 The script and the fraktur alphabets can be easily set up with the mathalpha package, but for historical reasons there also exist individual packages to set them up. For the script alphabet you can alternatively use the eucal package, which makes this math alphabet available under the name . If the package is loaded with the mathscr option, the alphabet becomes available through the command , with retaining its original definition. The package for Euler Fraktur is eufrak, which defines the math alphabet . There is no particular package to access the Euler Roman alphabet separately.
The next example shows Computer Modern Calligraphic, Euler Script, and Euler Fraktur side by side. We use the mathalpha approach but also show the equivalent older way using the packages eucal and eufrak:
Unfortunately, the Euler fonts use font encodings that differ from all other encoding schemes for mathematics. For this reason, the fonts are all assigned the encoding U (unknown) in NFSS classification.
These nonstandard encodings make it difficult to simply substitute the Euler alphabets and symbols for the default CM math fonts. Yet the euler package, written by Frank Jensen, went exactly this way, redeclaring most of LaTEX’s math font setup. In conjunction with the package beton, which sets up Concrete as the default text font family, it simulates the typography of Knuth’s book Concrete Mathematics [58], as shown below:
12.3.4 newtxmath — A Swiss1 knife for math font support
In 2000, Young Ryu released a set of virtual fonts together with accompanying Type 1 fonts to provide math support for documents using Times Roman as the document font. LaTEX support was implemented through the package txfonts.
This implementation was fairly comprehensive in offering a large glyph set including all symbols from the American Mathematical Society fonts, but unfortunately it had some serious problems in that the glyph side-bearings in math were extremely tight, up to the point that characters actually touched if used in subscripts or superscripts. Compare the next two examples: the first is using the original TX fonts, while the second is using similar fonts prepared by Michael Sharpe.
Here is the same text but using newtxtext (Times as text font) and newtxmath (Times as math font). The latter package automatically loads amsmath, so strictly speaking we could have dropped that from the
call.
The differences may seems tiny, but they drastically improve readability, so instead of txfonts, you should always use the newer implementation by loading newtxmath. For the text font there are several possibilities, which is why Michael provided independent packages for text and math. You could can use his package or one of the Times fonts from Chapter 10 or any other text font that blends reasonably well with math based on Times.
12.3.5 newpxmath — Using the PX fonts for math
Besides support for Times in math, Young Ryu also developed a set of math fonts to work together with Palatino-like font families. These PX fonts were based on a Palatino Italic clone, together with all necessary symbols to cover all of the standard LaTEX and amsmath symbols. Unfortunately, just as with his TX fonts the PX fonts have metrics that are overly tight.
For this reason Michael Sharpe produced a new version, made a few glyph additions, and completely reworked the metrics. His fonts (New PX) are made available through the newpxmath package. Below are both fonts set side by side for comparison:
Michael’s package alters only the math setup, so you are free to combine it with any text font to which you think it fits with. Above we have combined it with his companion package for text, called newpxtext. This uses an augmented version of TEX Gyre Pagella (Palatino clone) with superior figures and an additional set of larger small capitals added. You can activate them in your document by adding the option largesc. The package also sets up TEX Gyre Heros (Helvetica clone) appropriately scaled as the sans serif family; this can be prevented through the option nohelv. Figure 12.10 on page 269 shows the combination of newpxtext and newpxmath on a sample page.
Most of the general functionality seen with the newtxmath package is also available with newpxmath, so we rehash it here only with a few examples. There is the same extended set of integrals available both in slanted form (default) or upright when using the option upint. You can explicitly select either form by appending up or sl to the command names.
12.3.6 mathpazo — Another Palatino-based approach for math
A package named mathpple supporting Adobe Palatino with matching math fonts was originally developed by Walter Schmidt (1960–2021) based on earlier work by Aloysius Helminck. It was built on the virtual font mechanism, combining symbols from Palatino, Symbol, Euler, and CM Math. Because these fonts only partly match the style of Palatino, Diego Puga developed a set of Type 1 fonts (Pazo Math) intended to repair the defects apparent in the initial mathpple solution.
The Pazo Math fonts contain glyphs that are unavailable in Palatino and for which Computer Modern or glyphs from Symbol look odd when combined with Palatino. These include a number of math glyphs, the uppercase Greek alphabet (upright and slanted), a blackboard bold alphabet, as well as several other glyphs (such as the euro symbol) in regular and bold weights and upright and slanted shapes.
The fonts are accessible with the mathpazo package developed by Diego Puga and Walter Schmidt as part of the PSNFSS collection. It makes Palatino the document text font and provides a math setup that works by using virtual fonts accessing Palatino Italic, the Pazo Math fonts, and CM fonts (for the remaining symbols).
The package supports the option slantedGreek to make uppercase Greek letters slanted instead of upright (the default). In either case the two extra commands and print an upright ∆ and Ω, respectively. The package also provides the functionality of the exscale package.
Pazo Math has bold font variants, but in contrast to the PX fonts, it does not offer dedicated fonts replacing the American Mathematical Society symbol fonts. Thus, the latter are unavailable (unless you additionally load amssymb), and they do not change their weight in a bold context if that package is loaded.
12.3.7 notomath — Setting up Noto fonts for math and text
The Noto fonts is a huge collection of text fonts in Serif, Sans, and Mono designs available as OpenType fonts for many languages and scripts across the world. There are also Type 1 versions in T1 and other encodings (see Table 10.14 on page 28), and these are supported by Bob Tennent’s noto package.
As part of newtxmath (with the option noto or notosans) Michael Sharpe provides math support for the Noto families; thus, in principle, his package, together with Bob’s, would be sufficient to set a whole document in Noto Serif or Noto Sans. There are, however, a few wrinkles that make combining them nicely a bit awkward. Michael, therefore, offers notomath as a simple frontend package that does all necessary work for you behind the scenes.
If you want a document in Noto Serif, all you have to do is to load the package without options. This sets up Noto Serif for the body text and Noto Sans for Both families are slightly scaled down to better fit with the mathematical symbols.
If instead you want Noto Sans as your main document font, add the option sfdefault. This changes the but leaves the untouched; thus, till produces Noto Serif.
Note that the typewriter family is not set up— the package uses whatever has already been set up when it is loaded. Thus, to be able to use the typewriter font in text also with math (via ), you should do the typewriter setup first. However, if you want to use Noto Mono as the typewriter font, you can simply specify the option mono. This then loads and scales down the family appropriately.
Package options that are relevant to the noto package can be given to notomath, which passes them on, e.g., oldstyle or proportional to alter the figure style. Similarly, the general options for newtxmath can all be given to notomath too, e.g., varbb or upint, but not those that change the math italic glyphs, e.g., stix2.
Figure 12.38 on page 287 shows a sample page using a Noto Serif setup, and in Figure 12.50 on page 295 you can study the same sample using Noto Sans instead.