Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I indicate an en-dash while in math mode using LaTeX?

Tags:

latex

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.

like image 909
Chris Duncombe Rae Avatar asked Jan 12 '09 20:01

Chris Duncombe Rae


People also ask

How do I type an en dash in LaTeX?

Inserting an en-dash in Latex. Type two hyphens with no space between them like–this. Latex will automatically turn it into an en-dash.

How do you write dashes in LaTeX equations?

To define a hyphen for use as part of a hyphenated name in a macro, I used the command \def\mymathhyphen{{\hbox{-}}} . This gives the usual en-dash.

How do I insert an en dash symbol?

Insert an Em or En dash using shortcut keys To create an Em dash, use the shortcut key combination Ctrl + Alt + - . To create an En dash, use the shortcut key combination Ctrl + - . Num Lock must be enabled and you need to use the minus key on the numeric keypad.


1 Answers

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). 
like image 147
godbyk Avatar answered Sep 19 '22 11:09

godbyk