# Difference between \mathit and math-style = TeX

I would like to know what the difference is between \mathit and setting [math-style = TeX] regarding italics in math mode.

This code will explain it better

\documentclass{article}

\usepackage[math-style = TeX]{unicode-math}

\begin{document}

$\mathit{\rho} \rho$

\end{document}


Only the latter showing up with an "italic" style (TeX math-style).

If an unicode math font such as STIX Two Math is loaded, the same will happen, but this time a cross inside a rectangular box will show up as \mathit{\rho}

Here's the code for said scenario

\documentclass{article}

\usepackage[math-style = TeX]{unicode-math}

\setmathfont{STIX Two Math}

\begin{document}

$\mathit{\rho} \rho$

\end{document}

• use \symit{\rho} However, it is already the same as \rho – user2478 Feb 4 '18 at 8:04
• The unicode-math package provides the directives \symit ("symbol italic") and \symup ("symbol upright"). These directives may be used to override the defaults set by the math style (TeX, ISO, french, or upright) that's in effect. (The default math style is TeX.) – Mico Feb 4 '18 at 11:12
• Why does \symit not show italic numbers? – Suppboi Feb 5 '18 at 14:55

I would like to know what the difference is between \mathit and setting [math-style = TeX] regarding italics in math mode.

There's a huge difference between (a) loading the unicode-math package and selecting a math-style (e.g., "TeX" or "ISO") that employs italics for lowercase Latin and Greek letters and (b) using \mathit. (Aside: For more information on the math styles provided by the unicode-math package, see section 5.1 of the package's user guide.)

Using \mathit operates quite independently of the chosen math style. Using \mathit can generate outcomes which may be unexpected -- at least at first. This is because the \mathit directive accesses its letters from the text font, not from the math font. This is by design. According to David Carlisle's comment (see below), \mathit should be used for multi-letter identifiers, such as the names of variables. For variable names, it's better to use italics from the text font, rather than "true" math-mode italics.

Consider the table below, which shows the four available math styles (ISO, TeX, french, and upright), with lowercase and uppercase Latin and Greek letters. The math font is set to Stix Two Text, while the text font is set to Calibri. I chose a sans-serif text font to make the difference between text and math fonts glaringly obvious.

Confirming what I asserted above, observe that the \mathit output, shown in the final column, does not employ letters from the math font family. Instead, it quite evidently employs letters from the text font family.

\documentclass{article}
\usepackage{array}
\newcommand\myarray[1]{\par\noindent%
% Structure of table:
%col. 1: math style
%col. 2: math mode, lowercase Latin letters
%col. 3: math mode, uppercase Latin letters
%col. 4: math mode, lowercase Greek letters
%col. 5: math mode, uppercase Greek letters
%=col. 6: output of \mathit
$\begin{array}{@{}p{1.2cm} >{$}p{1cm}<{$} *{3}{>{$}p{0.6cm}<{$}} l } #1 & abcffi & XYZ & \alpha\beta\gamma & \Phi\Psi\Omega & \mathit{abcffi} \\ % <-- final column uses "\mathit{...}" \end{array}$}

\usepackage{unicode-math}
\setmainfont{Calibri}[ItalicFont="Calibri Italic"] % sans-serif text font
%% or: \setmainfont{Stix Two Text}

\begin{document}
\setmathfont{Stix Two Math}[math-style = ISO]
\myarray{ISO}

\setmathfont{Stix Two Math}[math-style = TeX]
\myarray{TeX}

\setmathfont{Stix Two Math}[math-style = french]
\myarray{french}

\setmathfont{Stix Two Math}[math-style = upright]
\myarray{upright}
\end{document}

• nice answer but not sure why you say that the fact that \mathit uses a text italic is of historical interest. that was always (and still now) the main point of the command and why it should be used for multi-letter identifiers in preference to the math italic font. – David Carlisle Feb 4 '18 at 15:14
• @DavidCarlisle - Many thanks for this comment! I was actually unaware until just now of the real reason for why \mathit uses glyphs from the text font rather than from the math font. (Until now, I was never sure why \mathit behaves so differently from the plain-TeX \mit directive!) I will edit the paragraph in question accordingly. – Mico Feb 4 '18 at 15:17
• By design, plain tex \it has a definition \ifmmode math version \else text version\fi latex splits that and has separate \mathit and \textit commands. – David Carlisle Feb 4 '18 at 15:22
• @DavidCarlisle - Thanks - I just learned something new again! :-) – Mico Feb 4 '18 at 15:26
• No italic numbers though, why? – Suppboi Feb 5 '18 at 14:56