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.
LaTeX中有四种“破折号”:连字符,短划线( - ),em-dash(---)和减$ - $。它们分别用于连字和连接词,表示范围,标点符号和数学符号。我的问题是:如何在数学模式中指出一个短划线(范围)? (如$ S = 1到2 $)?我是否必须在'等式'中间退出数学模式($ S = 1 $ - $ 2 $)?或者有一个我可以使用的符号并保持在数学模式?我试过$ S = 1 \ - 2 $但是这给了我一个减号,而不是一个短划线,$ S = 1--2 $给出两个减少。我的猜测是我将不得不退出数学模式,但也许有一种方法可以做到这一点。
4 个解决方案
#1
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$
.
最简单的方法是使用$ S = 1 \ mbox { - } 2 $。但是,如果您在文档的序言中已经有\ usepackage {amsmath},那么最好使用\ text:$ S = 1 \ text { - } 2 $因为\ text会调整字体的大小超级和下标:$ 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:
数学中使用的短划线很容易与减号混淆。您可能希望查看其他技术来指示范围,例如省略号(基线上的点的\ ldots [逗号之间使用],或者居中点的[cdots] [在居中的运算符之间使用,例如加号])或使用括号符号。一些例子:
$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).
#2
You can use \textrm
which does not depend on \usepackage{amsmath}
. Some examples:
您可以使用不依赖于\ usepackage {amsmath}的\ textrm。一些例子:
$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.
或者也许使用\ textnormal而不是\ textrm。另请参阅LaTeX:在数学中使用\ textnormal而不是\ textrm(或\ textsf)。
#3
Well, 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.
好吧,你可以使用$ 1 \ mbox { - } 2 $,但我会查看符号列表中的数学符号列表。嗯。我找不到一个。
#4
Use the command \leftrightline in the package MnSymbol. I don't know if it's the length needed for your purposes, but hopefully it will do the trick.
在包MnSymbol中使用命令\ leftrightline。我不知道这是否是你所需要的长度,但希望它能解决问题。
#1
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$
.
最简单的方法是使用$ S = 1 \ mbox { - } 2 $。但是,如果您在文档的序言中已经有\ usepackage {amsmath},那么最好使用\ text:$ S = 1 \ text { - } 2 $因为\ text会调整字体的大小超级和下标:$ 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:
数学中使用的短划线很容易与减号混淆。您可能希望查看其他技术来指示范围,例如省略号(基线上的点的\ ldots [逗号之间使用],或者居中点的[cdots] [在居中的运算符之间使用,例如加号])或使用括号符号。一些例子:
$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).
#2
You can use \textrm
which does not depend on \usepackage{amsmath}
. Some examples:
您可以使用不依赖于\ usepackage {amsmath}的\ textrm。一些例子:
$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.
或者也许使用\ textnormal而不是\ textrm。另请参阅LaTeX:在数学中使用\ textnormal而不是\ textrm(或\ textsf)。
#3
Well, 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.
好吧,你可以使用$ 1 \ mbox { - } 2 $,但我会查看符号列表中的数学符号列表。嗯。我找不到一个。
#4
Use the command \leftrightline in the package MnSymbol. I don't know if it's the length needed for your purposes, but hopefully it will do the trick.
在包MnSymbol中使用命令\ leftrightline。我不知道这是否是你所需要的长度,但希望它能解决问题。