How do I indicate an en-dash while in math mode using LaTeX?
You can use \textrm
which does not depend on \usepackage{amsmath}
.
Some examples:
$S=1\textrm{--}2$
$S_{1\textrm{--}2}=0$ % correctly changes the font size for subscript
$S_{1\textrm{2}2}=0$ % does not change the font size :(
Or maybe use \textnormal
instead of \textrm
.
See also LaTeX: use \textnormal instead of \textrm (or \textsf) in math.
The simplest way is to use $S=1\mbox{--}2$
. If you already have \usepackage{amsmath}
in your document's preamble, however, you're better off using \text
: $S=1\text{--}2$
because \text
will adjust the size of the font when used in super- and subscripts: $S_{1\text{--}2}=0$
.
An en dash used in math may easily be confused with a minus sign. You may want to look at other techniques for indicating a range such as ellipses (\ldots
for dots on the baseline [used between commas], or \cdots
for centered dots [used between centered operators such as plus signs]) or using the bracket notation. Some examples:
$S = \{1, 2, \ldots, n\}$ indicates an element in the set containing integers between 1 and $n$.
$S = [0, 1]$ indicates a real number between 0 and 1 (inclusive).