17.1 \ensuremath



Ensure that formula is typeset in math mode.

For instance, you can redefine commands that ordinarily can be used only in math mode, so that they can be used both in math and in plain text.

In $\int f(x)\, \dx$, the \dx{} is an infinitesimal.

Caution: the \ensuremath command is useful but not a panacea.

You get an alpha in text mode: \alf.
But compare the correct spacing in $\alf+\alf$ with that in \alf+\alf.

Best is to typeset math things in a math mode.

Unofficial LaTeX2e reference manual