[Tex/LaTex] Inline math or \textit for author defined math constants

best practicesfontsmath-mode

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?

Best Answer

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.