Write Text inside Math Mode: Tips + Examples

In LaTeX math mode, spaces are overlooked, and letters are rendered in italics. Hence, in order to add normal text, we need special commands such as \text, \textrm, \mbx and \textnormal. This post discusses these methods and highlight the difference through illustrative examples.

  1. Method 1: \text<> command
  2. Method 2: \textrm<> command
  3. Method 3: \mbox<> command

Method 1: \text<> command

In LaTeX, the command \text<> with package amsmath is used to add normal text in math in LaTeX. Here is an example:

% Method 1 using \text command \documentclass % Required package \usepackage \begin $\text x=\text. $ \end

Output:

From the above example, the command \text<> is used to print Let and Countries participated in the marathon in normal text in math mode in LaTeX

Method 2: \textrm<> command

The command \textrm forces the roman font style for text and keeps font parameters from the current text font. It should be noted that font size is the same as the current math style if the package amsmath is loaded. Check the following code:

% Method 2 using \textrm command \documentclass % Required package \usepackage \begin $\textrm x=\textrm. $ \end

Method 3: \mbox<> command

In LaTeX, the command \mbox<> can be used to add normal text in math environment in LaTeX. \mbox<> command creates a box to hold the text and uses the current text font. It should be noted that the font size is constant and does not change, e.g. in subscripts, superscripts, and fractions. Here is an illustrative example:

% Method 3 using \mbox command \documentclass % Required package \usepackage \begin $ \mbox x_<\mbox.> $ \end

Output:

You can remark that \text command updates the font size to meet the subscript font size which is not the case with \mbox .