6

I am using photoshop to make a figure and I needed the same font used in LaTeX math mode. Other questions on this site all lead to "latin modern math" as the math mode font. For some letters (greek psi, for example), they look pretty right, but some are obviously incorrect. For example, the x in latin modern math is:

enter image description here

but in latex, it is

enter image description here

I can confirm that the problem is not just italics. The italic x in LMM doesn't have the fancy-serifs that the mathmode x has. The other letters are also obviously off.

What is the correct font for math mode and where can I find it?? The only other post I saw referenced the computer modern fonts on this website https://ctan.org/tex-archive/fonts/cm/mf but they are in an mf format; I was only able to find one mf converter which didn't work for these files.

1
  • 2
    You need to use the correct characters: U+1D464 and following, 𝑤𝑥𝑦𝑧 (these are not LMM, but you can copy-paste them).
    – egreg
    Jan 20, 2020 at 17:54

3 Answers 3

8

This is very near to be off-topic.

If I choose Latin Modern Math on a word processor such as TextEdit and type wxyz I get the top line.

If I use the Unicode characters U+1D464, U+1D465, U+1D466 and U+1D464 I get the bottom row.

enter image description here

Pasting the text in a format checker such as https://r12a.github.io/app-conversion/ and converting, I get

enter image description here

Here' a description for the “mathematical w”:

enter image description here

1
  • This is so helpful, thank you so much for the advice. Unfortunately the problem still isn't completely solved, because after downloading the font from 3 different sources, the set of abcd....xyz which you posted doesn't have "h" in any of the downloaded versions. Maybe you know the reason for this better than I, or where one could find the correct h? Jan 21, 2020 at 10:42
3

To answer your literal question, only if you load unicode-math. Latin Modern Math is a clone of Knuth’s Computer Modern, and unicode-math produces nearly-identical output under the default settings (with a few caveats: the \mathcal alphabet is based on Euler Calligraphic instead of traditional LaTeX). A legacy TeX document would use some legacy 8-bit or even 7-bit font instead. There are numerous versions of Computer Modern out there, with slight differences. Knuth’s original TeX fonts were specified in METAFONT and compiled to bitmaps. A modern TeX distribution would, by default, embed one of several different PostScript Type 1 fonts.

There are two conversions of the Computer Modern family to OpenType, Latin Modern and Computer Modern Unicode, and those are what you would want to use with modern software. You might find this table of Unicode math symbols helpful. The L column shows their rendering in Latin Modern Math.

Most of the fonts you found with pdffonts have direct conversions into the Computer Modern Unicode fonts, as you can see in the table here. For example, CMMI10 corresponds to CMU Serif Italic or Latin Modern Roman 10 Italic.

The problem you were having is that Latin Modern Math uses the mappings defined by Unicode. That is, they map letters such as x, y and z to the \mathrm alphabet, and all the other mathematical alphabets are in the Mathematical Alphanumeric Symbols or Letterlike Symbols block. You could also substitute the italic text font. You would want to load the MATH OpenType feature, and the ssty option on your superscripts and subscripts to properly extend them, at level 2 if you have nested superscripts or subscripts. Only Latin Modern Math supports this feature. The Latin Modern text fonts support the different sizes of the Computer Modern family through the optical size feature.

The default behavior of LaTeX math mode is to typeset uppercase Greek letters as upright (in the Greek Unicode block) and lowercase Greek letters as slanted (in the Mathematical Alphanumeric Symbols block), with a few other mathematical variants (such as \theta/vartheta) tossed in elsewhere as symbols. The Latin Modern text fonts do not cover Greek letters, but the CMU serif fonts do. If you select the Greek script as an OpenType feature, you’ll get letters that look like modern Greek typography. To get shapes that look like $\theta$ or $\lambda$ in CMU Serif, do not load an OpenType script.

If you just want the outlines and typesetting, one option might be to render your equation with \documentclass{standalone} and convert it to a SVG image that you can embed in your project. This will get all the fiddly little details of spacing right.

2

Upon further inspection it seems the other answer wasn't right. Okay, maybe the glyphs were right, but I needed a full set of characters, and for whatever reason "h" was missing, and it turns out the full story is more complicated. To figure out which fonts are used I analyzed a pdf document containing just a bunch of letters in math mode. An example result (from "pdffonts" cmd line tool) is:

name type encoding emb sub uni object ID

------------------------------------ ----------------- ---------------- --- --- --- ---------

FFIQJR+CMMI10 Type 1 Builtin yes yes no 4 0

RLKJHN+CMR10 Type 1 Builtin yes yes no 5 0

CMMI10 was the font I was looking for. And for this font, the correct characters are not special unicode characters, just the regular abcde...xyz, etc. CMMI stands for Computer Modern Math Italic.

However, adding more characters reveals that more than one font is used by default. I have been testing and so far, my results are

cmmi10 for abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, comma, period, ><, lowercase greek

cmr10 for upper case greek 0123456789 and ?+=!()

cmsy10 for -* \to \ll \gg \leq \geq \approx \dagger

Update: I have used the program fontforge to combine these different fonts into one custom font, so that one can just type like normal (or use the default unicode characters for greek letters etc) and it will look like math mode. I didn't copy in every single character but I included all of the most useful characters and then some. It's a combination of cmmi10, cmr10, and cmsy10. In case it is helpful to other users, you can download it here: https://drive.google.com/file/d/1NyH1rAtnCgJSsmZS_PWmm3f3k-oBCRUx/view?usp=sharing

The individual fonts that it is composed of can be downloaded here: https://ctan.org/tex-archive/fonts/cm/ps-type1/bakoma/ttf/?lang=en however in seemingly random cases a single glyph was missing, for example it has "greater than or equals", but not "less than or equals". So far I have been able to find the missing glyphs by searching for the same font from a different website.

4
  • 4
    For the missing “h”, blame the Unicode Consortium; they already defined the math italic “h” as the Planck constant U+210E and didn't fill the hole in the Mathematical Italic block, which is a silly decision.
    – egreg
    Jan 21, 2020 at 15:09
  • @egreg Sigh: I'll need to allow for that in 'text purification'
    – Joseph Wright
    Jan 22, 2020 at 12:00
  • 1
    @JosephWright I was thinking whether unicode-math should define \mith anyhow.
    – egreg
    Jan 22, 2020 at 12:01
  • 2
    Where have you been all my life! @doublefelix thank you for sharing your solution and making everyone's life way easier. This solution is way more straightforward than the other ones.
    – RemiDav
    Dec 20, 2021 at 5:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .