10

Wondering if people here have a thought on what the best practice is here (if it matters).

I used to use baskerville (well, the baskervald package) as my main font and charter as my math font (since baskerville has no math font). Since there was a slight difference in the style of the italicized font, I would put all author defined constant symbols (e.g., "Let a be a number such that....") in text in inline math mode environments to preserve a consistent look between occurrences of that symbol in the text and in equations.

Now I use Palatino (or whatever you'd call the Palatino equivalent provided by mathpazo) and so don't have to worry about the font matching issue, is there any difference between $a$ and \textit{a} in that case? I think I'd still prefer to use $a$ since it makes more sense semantically (math constants in math mode....), but I'm wondering if there are any downsides or really any differences at all.

Is the italic math "a" any different from the italic text "a"? Is there any reason to prefer \texit{a} to $a$?

Bonus Question (that would be nice, but not mandatory, for an answer to address): where can I find information about math fonts and how LaTeX calls them?

1
  • 2
    If you ever need to convert your document to Word format, it is less messy if you use \textit as you otherwise end up with a separate frame for every single occurrence of every such constant mentioned in your text, whereas \textit will just be converted to a switch to italic and back. I still tend to use inline maths just because it makes semantic sense but it is definitely a disadvantage when it comes to conversion.
    – cfr
    Feb 26, 2014 at 0:21

3 Answers 3

10

Definitely you should use math, $x$ or for multi-letter identifiers $\mathit{foo}$ even if as appears to be the case here the fonts are virtual fonts using the same glyphs, they are, to LaTeX different fonts with different encodings and metrics. Even if the letters you are using happen to have the same metrics, the document is then very fragile and will do the wrong thing if you ever change the font options. Somewhere Knuth (if I recall correctly) writes how he was caught out using digits as 1 rather than $1$ which produces the same output in computer modern (and most other) font setups but broke in (I think) concrete math setup where the math and text digits were in different styles.

A small example using mathpazo

\documentclass{article}

\usepackage{mathpazo}

\begin{document}
\showoutput

x \textit{a} x $\mathit{a}$ x $a$ x


x \textit{fi} x $\mathit{fi}$ x $fi$ x

x \textit{i} x $\mathit{i}$ x $i$ x

\end{document}

which produces

output

or perhaps more usefully:

...\hbox(4.83499+0.09998)x345.0, glue set 295.24033fil
....\hbox(0.0+0.0)x15.0
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/it/10 a
....\kern 0.0
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\mathon
....\OML/zplm/m/it/10 a
....\mathoff
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 4.57007
...\hbox(7.32996+2.76498)x345.0, glue set 275.09068fil
....\hbox(0.0+0.0)x15.0
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/it/10 ^^L (ligature fi)
....\kern 0.0
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\mathon
....\hbox(7.32996+2.75987)x5.27989
.....\OT1/ppl/m/it/10 ^^L
....\mathoff
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\mathon
....\OML/zplm/m/it/10 f
....\kern1.09999
....\OML/zplm/m/it/10 i
....\kern0.06999
....\mathoff
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\baselineskip) 2.12003
...\hbox(7.11499+0.09998)x345.0, glue set 285.77068fil
....\hbox(0.0+0.0)x15.0
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/it/10 i
....\kern 0.0
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\mathon
....\OT1/ppl/m/it/10 i
....\mathoff
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\glue 2.5 plus 1.49998 minus 0.59998
....\mathon
....\OML/zplm/m/it/10 i
....\kern0.06999
....\mathoff
....\glue 2.5 plus 1.49998 minus 0.59998
....\OT1/ppl/m/n/10 x
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0

Where you can see that the math fonts don't have the fi ligature and introduce a small kern after the i which is not in the text font.

5
  • Wow! I figured the difference between the two would be minimal. Bertrand's answer convinced me that might not be the case. Your answer has convinced me never to use \textit for these sorts of cases.
    – Dennis
    Feb 26, 2014 at 2:26
  • the knuth reference to differences in numeral style is in the tugboat article Typesetting Concrete Mathematics. Feb 26, 2014 at 15:15
  • @barbarabeeton see, I do read your journal:-) Feb 26, 2014 at 17:57
  • @DavidCarlisle -- oh, i know you read it, at least once in a while. i just thought if someone else saw your comment, they might like to read the original for themselves. Feb 26, 2014 at 20:02
  • @barbarabeeton yes thanks (and thanks for confirming my memory still works) Feb 26, 2014 at 20:04
6

If you look at this link, you will understand that placing a math chararacter is different from placing in italic letter, because the metrics are different: one has to take into account that a letter may have an exponent or an index, for instance, so that the sidebearings are different. Actually, when TeX uses 7 parameters for a text font, a math font requires at least 22 (the "fontdimens").
That is mainly why one cannot just say "I will take this italic text font for letters in maths" – and why there aren't many math letters fonts.

2
  • Very interesting, didn't know about this. When you use a font family with math font support, though, (like when calling mathpazo) are there two different italicized "a"'s? One with 7 parameters and one with at least 22? Or is there just one italicized "a" in the font family that has at least 22 parameters, only 7 of which ever get adjusted when used as text fonts? I'm a bit unclear as to what is gets included under the term "math font".
    – Dennis
    Feb 26, 2014 at 0:54
  • 1
    The contours of the letter are the same as it's based on a postscript (type 1) font. What changes is the metrics file, which is different. More over, TeX has its own system of metrics (the .tfm files), which is different (but deduced in such a case) from the Adobe metrics files (.pfm for windows system, .afm for unix-type systems. TeX sees characters as boxes, that it has to fit together; what's in the box is the same, but the dimensions of the box is slightly different for math fonts and for text fonts, because it has to compose math formulae harmoniously.
    – Bernard
    Feb 26, 2014 at 1:32
4

Somewhere (that I frustratingly now can't find!) I read that ISO (or a similar standards group) recommends (mandates?) for physics to write slanted (i.e., math italics or similar) for variables, and use upright (i.e., math roman) for constants, specifically for mathematical constants. So the exponential function is $\mathrm{e}^x$, the speed of light is written $\mathrm{c}$, and time is usually represented by $t$.

Don't presume the body and math fonts will match always, somebody will come along and mess it up.

Do it the LaTeX way: Say what you mean, don't write for visual effects. The resulting document (source) will be more robust (think about filching a few paragraphs for a new document in a different style) and easier to understand.

5
  • The "LaTeX way" is why I prefer the more semantically transparent (imho) inline math approach. Thanks for your thoughts on this. One question, though, when you say "...somebody will come along and mess it up..." what are you predicting? Are you predicting that the fonts called by a package like mathpazo will be altered in some way?
    – Dennis
    Feb 26, 2014 at 0:51
  • @Dennis, no. But some day you'll want to try another font family (you said you changed recently, didn't you?). And you will want to reuse part of your old texts, or reformat them.
    – vonbrand
    Feb 26, 2014 at 1:03
  • Ah ok, now I understand the concern. Better to use $a$ because then reformatting becomes easier if, say, I adopt the convention of putting all constants in uprights like you mention.
    – Dennis
    Feb 26, 2014 at 1:12
  • @Dennis, in fact I'd write \(...\) , as I prefer to have visual open/close.
    – vonbrand
    Feb 26, 2014 at 1:23
  • No way. I'm a physicist, and I have never seen a physics paper or book that puts a constant like c upright just because it's a constant.
    – user6853
    Mar 1, 2014 at 21:06

You must log in to answer this question.

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