Modes

As LaTeX processes your document, at any point it is in one of six modes. They fall into three categories of two each, the horizontal modes, the math modes, and the vertical modes. Some commands only work in one mode or another (in particular, many commands only work in one of the math modes), and error messages will refer to these.

For instance, if you begin a LaTeX article with ‘Let \( x \) be ...’ then these are the modes: first LaTeX starts every document in vertical mode, then it reads the ‘L’ and switches to paragraph mode, then the next switch happens at the ‘\(’ where LaTeX changes to math mode, and then when it leaves the formula it pops back to paragraph mode.

Paragraph mode has two subcases. If you use a \parbox command or a minipage then LaTeX is put into paragraph mode. But it will not put a page break here. Inside one of these boxes, called a parbox, LaTeX is in inner paragraph mode. Its more usual situation, where it can put page breaks, is outer paragraph mode (see Page breaking).


\ensuremath

Synopsis:

\ensuremath{formula}

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.

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

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

\newcommand{\alf}{\ensuremath{\alpha}}
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.


Up: Modes   [Contents][Index]