Italic maths is a convention about meaning: every italic letter is a variable and every upright word is a name. Read it that way and "why is my text italic" answers itself — and the fix is always a switch of alphabet, never a font. The switches are \mathrm, \mathbf, \boldsymbol and \mathit; which one applies depends on whether the symbol is Latin, Greek or a whole word (Greek Letters, Trigonometric Functions).
Which one to use
x, y, \alpha\sin, \log\operatorname{rank}\mathbf{v}\boldsymbol{\alpha}\mathbf will not do it.The commands
\mathbf{v} \quad \mathbf{Ax} = \mathbf{b}
\mathbf has nothing to offer. \boldsymbol{\omega}
\mathit{ABC}
\mathrm{d}x \quad \mathrm{Var}(X)
\mathrm alone does not give you. \operatorname{sn}(x)
\mathbb{R}^n \quad \mathbb{E}
\mathcal{L}\{f\}
\mathfrak{sl}_2
\mathsf{T} \quad \mathsf{queue}
\mathtt{lambda}
Worked examples
The italic default explained
ab \ne a b \neq \mathrm{ab}
All three print nearly alike, which is precisely the problem: LaTeX treats adjacent letters as an implicit product unless you say otherwise.
Units need out of italic
E = mc^2 \quad t = 5\,\mathrm{s}
A unit symbol is a name, not a variable, so an italic s invites reading it as seconds times something.
Bold face versus bold Greek
\mathbf{F} = m\mathbf{a} \quad \boldsymbol{\tau} = \mathbf{r} \times \mathbf{F}
Where a bold torque symbol is needed, \mathbf will not do it; this is the single most common font error in mechanics.
Differentials set upright
\int_0^1 x\,\mathrm{d}x
ISO style asks for an upright d. Whether you follow it matters less than following it consistently.
Common mistakes
- Using
\text{max}inside maths when\maxexists. The text form loses the operator limits and the correct surrounding space. - Writing
\mathbf{\Omega}for a bold omega. It produces an upright bold capital that looks wrong next to a bold lowercase set;\boldsymbol{\Omega}matches. - Setting a multi-letter variable as
massand expecting it to read as one quantity. It parses as m·a·s·s; wrap it in\mathit{mass}or rename the variable. - Reaching for
\bm{...}outside a LaTeX document. It is a package command and KaTeX defines it only as a thin alias, so\boldsymbolremains the portable choice.
Questions about this notation
Why are my variables italic in LaTeX?
\sin and \log have to be commands rather than typed plainly.What is the difference between \mathbf and \boldsymbol?
\mathbf selects the bold upright Latin alphabet and ignores everything else. \boldsymbol switches the whole maths symbol font to its bold variant, so it reaches Greek letters, operators and symbols.How do I make a variable upright?
\mathrm{x} for a single symbol, or \operatorname{name} when it behaves as a function. Note that \mathrm changes the shape but not the grammatical class, so spacing around it stays that of an ordinary symbol.How do I write a bold vector that keeps its Greek letters and symbols bold?
\mathbf affects letters and digits only, so \mathbf{\Gamma v} leaves the Gamma light without warning you. The bm package fixes that: \bm{\Gamma v} bolds every symbol in its argument and keeps maths italic, which is what a vector wants. Without an extra package, \boldsymbol{\Gamma} from amsfonts covers the Greek case.Keep reading
Three ways into the same idea: the notation itself, the lesson that teaches it, and an article that applies it.