There are four kinds of 'dashes' in LaTeX: hyphen, en-dash(--), em-dash(---) and minus $-$. They are used for, respectively, hyphenation and joining words, indicating a range, punctuation, and a mathematical symbol. My question is: how do I indicate an en-dash (range) in math mode? (as in $S=1 to 2$
)? Do I have to drop out of math mode in the middle of the 'equation' ($S=1$--$2$)
? Or is there a symbol I can use and stay in math mode? I tried $S=1\--2$
but this gives me a minus, not a en-dash, and $S=1--2$
gives two minuses. My guess is I am going to have to drop out of math mode but maybe there is a way to do it without that.
views:
1893answers:
3Well, you could use $1\mbox{--}2$
, but I'd look at the list of math symbols in the symbol list. Hmm. I don't find one.
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).
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.