People who would like to get scientific papers published while learning the smallest possible amount about how the typesetting engine works

LaTeX has been around for a few decades now, and a lot of stuff has happened in that time, e.g. they invented the € symbol. Here is how one keeps up with the typographical times.

First, be aware that there are many systems for encoding characters and information about them that can be used by TeX. There are font encodings with names like T1, OT1, T2C, R2D2 and what-have-you. There are also a distinct set of, I think, character encodings. There is also the modern solution of using unicode systems (which in practice means utf8 encoding), supported by modern desktop fonts. Encodings have to map to fonts, which means that fonts must support the desired encodings. The systems that make this work are nowadays routine for European text but less so much for non-European scripts or mathematical text. In particular, when combining LaTeX’s recondite quirks with popular modern cosmopolitan text handling, friction arises. The main point is — it would be nice if all this were easy and transparent, but it is not, so let us see if we can learn the minimum possible about this entire dire situation so as to survive it.

1 Unicode

As far as my shaky understanding goes, there are two encodings you need to care about in LaTeX: the character encoding, which controls how LaTeX understands the document engine, and the font encoding, which determines which glyph is pulled out of the font to represent the text when you write to PDF or print the thing out.

Classic LaTeX/pdfLaTeX uses ASCII or some other such basic American font encoding for the character encoding, but these days can be browbeaten into accepting UTF-8 for unicode character encoding.

Modern LaTeX variants such as XeLaTeX/LuaTeX etc use unicode throughout (?). I think.

For a long, useful, unexciting history of what on earth is going on see Frank Mittelbach et al, LATEX font encodings.

There is a whole other complicated side story for the mathematical parts of the document (which we set aside for the moment) to do with the fact that the font encodings for mathematical stuff are obscure or broken or difficult or something, presumably because back in the day we had 8-bit characters, and there are more glyphs in mathematics than can fit in 8 bits.

Anyway, caveats and qualms aside, I prefer to use unicode since it means I can copy and paste text from the internet without worry about diacritics making a mess of everything.

1.1 pdfLaTeX

pdfLaTeX can handle modern input encoding but not modern fonts, AFAICS. It is also the de facto standard and more-or-less works just enough that it can stagger on, so in general I need to know how to make it work. This is more complicated than, e.g., just using straight up XeTeX which has modern font mappings and understands unicode. However, modern solutions are not supported on arxiv.org.

My cargo-cult solution: I put this at the start of every file I touch.

XeTeX is my exemplar of “modern font LaTeX”. I have the vague idea most things that work with XeTeX are interchangeable with ConTeX and LuaTeX et al, but I have not tested that assumption.

\usepackage{mathspec}\usepackage{xunicode}% Fix incommensurability of font sizes which per default is awful% this line must come after mathspec or fontspec\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}\newcommand{\euro}{€}

This is incompatible with a couple of primordial packages which do fake Unicode hacks (like the ucs package) but AFAICT those are not actually needed.

For text, any modern font/font encoding just works AFAICT for the base document text. When doing Fancy Font Stuff, it can get tricky. Because some legacy packages are unmaintained hacks there are weird fragile problems that can arise where some package will try to mess with the fonts in a manner deemed inappropriate by modern standards.

If I decided to go hardcore unicode in XeTeX et al, I could use unicode even for mathematics (which is not the default), via unicode-math.

With this package, changing maths fonts is as easy as changing text fonts — and there are more and more maths fonts appearing now. Maths input can also be simplified with Unicode since literal glyphs may be entered instead of control sequences in your document source.

Also if I were to copy-paste equations from a PDF generated by such means to LaTeX, they would be somewhat less mangled. The price is its various quirks e.g. missing some curly letters. On the other hand, it has symbols that are in unicode but not in elderly Tex math fonts, such as ⫫, which I need essentially every day.

Usually I do not have a choice of maths fonts because versions are stipulated in the style guide for the journal/conference/thesis I am writing. Therefore, while this is nifty, the benefits are insufficiently many compared to the burdens. The logic of collective action dictates I ignore it for now.

What font is good for writing papers, though? Ideally I would like one that does not freak out my colleagues and also can handle mathematics (see below). XITS is a Times-like font for science that seems to soothe academics, who have a great fetish for cargo cult typography.

The package uses a text font (usually the document’s text font) for the letters of the Latin alphabet needed when typesetting mathematics. (Optionally, other characters in the font may also be used). This facility makes possible (for a document with simple mathematics) a far wider choice of text font, with little worry that no specially designed accompanying maths fonts are available. The package also offers a simple mechanism for using many different choices of (text hence, now, maths) font in the same document. Of course, using one font for two purposes helps produce smaller PDF files.

There are some battle-tested combinations in the manim typesetting engine, listed here. (source).

4 Mathematical fonts

I am not the person to ask about the intimate details of LaTeX font hell but see TUG font catalogue for traditional LaTeX mathematical font support and mathspec for XeLaTeX font support. To understand the intricacies of which font combinations work in practice, check out the Free math Survey. This is outdated now but is a good conservative starting point AFAICT.

tl;dr There is some complicated interaction between

main font and

math font (and possibly a special Greek font) and

typesetting engine, and

which format my fonts happen to be in, which BTW changes how one must install them, which is in turn dependent upon

the OS I am using and

which features I want and by the way

what my text encoding is.

If I get any one of those wrong there are weird, unhelpful errors. Best to copy-paste someone else’s work; Weird things happen with maths sometimes but it mostly seems to work in the end.

4.1 Classic mathematical fonts

Or nearly-classic, using Type 1 postscript fonts and whatever dark magic LaTeX uses to make those go. Here is a large selection of fonts, surely one of them works?

The above complicated interactions mean that configuring my document to use these is simultaneously terrifying and boring. Fortunately if I cargo-cult some example configurations things seem to work out OK. Here are some incantations that work for me:

The experimentally modern world of unicode-math (i.e. typesetting using modern unicode encodings and OpenType fonts) has a unicode math font list. On the plus side, there are fewer moving parts for unicode maths, so less ways to break it. On the minus side, those moving parts are still somewhat new and experimental and thus their failure modes are less well documented. If one is running minimalist TeX, one sets these parts up thusly

This package facilitates the use of fontspec for users who do not wish to bother with details, with a special focus on quality fonts supporting Mathematics. This package is a simple wrapper-type package that makes the setup of fonts easy and quick for XeLaTeX and LuaLaTeX. You just load the package using one of the supported fonts as an option. The target is to provide easy access to fonts with a matching Mathematics font available in TeX distributions plus a few commercial if available. The package will include more font combinations in the future, however there are some restrictions. The fonts must have some commercial-level quality and must support Mathematics