Style change – \usepackage{newtxmath}

This post is a quick annouce­ment that I changed the main text and math fonts and hope­ful­ly for the better.

Back­ground: This blog runs on Word­Press, using an almost vanil­la Twen­tyEleven theme and using the Quick­La­TeX plu­g­in for math type­set­ting. But while Word­Press uses a default sans-serif font (it explic­it­ly prefers Hel­veti­ca but also accepts any looka­like) the default font in \LaTeX is usu­al­ly Com­put­er Mod­ern, a com­plete­ly dif­fer­ence type­face. So with stan­dard set­tings, there was always going to be a font mis­match between text and math.

In order to mit­i­gate this, I pre­vi­ous­ly found Com­put­er Mod­ern Bright as an alter­na­tive \LaTeX font (see the old announce­ment post) that is a bet­ter match with Hel­veti­ca. CM Bright is one of the few sans-serif fonts in \LaTeX that has full math sup­port. But CM Bright also has issues, for exam­ple it is hard dis­tin­guish low­er­case l from upper­case I, and some of the gen­er­at­ed SVGs do not ren­der cor­rect­ly, espe­cial­ly if they are images of sin­gle letters.

Now I switched the main body text to Times, or what­ev­er the browser’s default serif font is. This is then com­bined with the newtx-pack­age on the \LaTeX-side, so now text and math use the same font (at least the­o­ret­i­cal­ly). See how this turns out for yourself:

a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9

    \[\text{a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9}\]

The top row is text-mode (your browser’s ver­sion of Times or a sub­sti­tute), the bot­tom row is math-mode (a ren­dered SVG image by \LaTeX). In both cas­es, the request­ed font size is explic­it­ly 16 pix­els. It is expect­ed that the match is not per­fect, espe­cial­ly that the met­rics will be slight­ly dif­fer­ent, but over­all it should be an improve­ment. I am aware that com­mon wis­dom usu­al­ly says that serif fonts are bad for online view­ing, but has­n’t this advice become obso­lete with high-DPI dis­plays? And boy does the Times font look sharp and seri­ous! Every blog post now auto­mat­i­cal­ly looks like a paper.

\usepackage{cmbright}

The ‘mod­ern’ look­ing sans-serif font I use recent­ly in \text{\LaTeX} equa­tions on this blog is called ‘Com­put­er Mod­ern Bright’, and actu­al­ly is not so mod­ern at all: Designed by Wal­ter Schmidt in 1996, it is still to date the only free sans-serif font avail­able for \text{\LaTeX} with full math sup­port. Type‑1 ver­sions of this font are avail­able in the cm-super pack­age, but I did­n’t need to install any­thing, because appar­ent­ly, the Quick­La­TeX Word­Press plu­g­in has them already. The only thing to do was adding just one line to the preamble:

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{cmbright}   % computer modern bright

I also turned on the SVG images fea­ture that was added with ver­sion 3.8 of Quick­La­tex, so the equa­tions are no longer pixel­lat­ed on reti­na dis­plays or when zoom­ing in! Neat, huh?