17

I've been using -16 in my LaTeX code to write negative numbers.

But the problem with that, is in many displays and LaTeX rendering kits, it displays the - sign as extremely long and separated from all the other mathematical symbols (e.g. the 16).

Since I knew that LaTeX is an extremely thorough, powerful and complex language, I thought there definitely must be a way to pass this slightly annoying problem.

I don't really want my users looking at a mile-long negative sign.

Is there a way?

Example: I don't want this - too wide and ugly.

  • 1
    You've added an image of exactly what I'd expect to see. I was thinking more of your input: that just looks like $-16$ to me. – Joseph Wright Oct 26 '12 at 7:16
  • 1
    Seems like it is related to tex.stackexchange.com/questions/6058/making-a-shorter-minus and tex.stackexchange.com/questions/4756/… to make it shorter I use \text{-} – jens_bo Oct 26 '12 at 7:52
  • 1
    @jenson_bo -- these examples are indeed related. but the important thing is that the hyphen (what you get with \text{-} is not equivalent to a minus sign. better would be an en-dash (\text{--}) since it has about the same thickness as a minus, but the vertical positioning is off. – barbara beeton Oct 26 '12 at 12:26
  • @barbara beeton --yes, I noticed the difference. In the answer I gave below I used \scalebox to get a shorter minus in math mode. – jens_bo Oct 26 '12 at 19:39
  • @jenson_bo -- the nonsymmetric scaling of the minus is a good solution. +1 but you might want to call it something other than \minus, and make it an "ordinary" character to guarantee that the spacing is dependable. – barbara beeton Oct 26 '12 at 19:46
22

I am not a fan of typing numbers in the text in mathmode. It's fine if you use a complete font, but what if you decide to change the math font later? I prefer to use the textminus from the textcomp package. If your editor is unicode capable you can enter the proper minus symbol directly.

Edit: siunitx is able to handle numbers correctly as well.

Edit 2: To respond a bit more to the question asked, there is no typographical difference between a 'minus' and 'negative' sign. The difference is the kerning: With $-12$ the sign is close to the number, with $10-12$ the minus has appropriate kerning between the numbers. In short, there should be no need to resize the minus sign for negative numbers as a good font should have a minus sign so that its length blends in well with text.

\documentclass{scrartcl}

\usepackage{textcomp}
\usepackage{mathpazo}
\usepackage{eulervm}
\usepackage[utf8]{inputenc}

\DeclareUnicodeCharacter{2212}{\textminus}% requires a unicode capable editor

\usepackage{siunitx}
\sisetup{
   detect-mode,
   detect-family,
   detect-inline-family=math,
}

\begin{document}

\noindent
Number \textminus10 (textcomp minus)\\
Number −10 (unicode minus)\\% requires a unicode capable editor
Number -10 (normal text minus)\\
Number $-10$ (all math mode)\\    
\vspace{1ex}
\noindent
Number \num{-16} (siunitx textmode. No bug, my bad. Sorry Joseph)\\
Number $\num{-16}$ (siunitx mathmode)

\end{document}

enter image description here

  • 2
    We don't have any context in the question, but in the main I'd expect negative numbers to be more 'mathematical' in usage than 'textual'. For example, something like a temperature is 'mathematical', whereas a section number is 'textual'. – Joseph Wright Oct 26 '12 at 10:45
  • @JosephWright Not sure I understand what you mean. Would you write something like today it is $-16$ degrees in a text? – Jörg Oct 26 '12 at 10:50
  • It would depend on the context. In something 'textual' (like a letter) I would write it out in words, but in something more 'mathematical' (like a paper for work) I would use $-16$ (or more likely siunitx in math mode). – Joseph Wright Oct 26 '12 at 10:54
  • @JosephWright Alright, but if you mix something like MinionPro and Euler that would look a little silly. Also, if you define lining numbers for math mode and OSF for text you mix the two in body text, which I think is typographically not correct. – Jörg Oct 26 '12 at 10:56
  • This is a nice compilation. Could you add the output of siunitx to your examples? I am curious how \num{-10} looks in comparison. Personally the textcomp minus looks just right. – Alexander Oct 26 '12 at 11:02
15

David's

Using a hyphen as in (3) is just horrible, it's all wrong.

got me thinking and I guess a nice alternative (if you don't like the default length) is to define the command \minus like that:

\documentclass{article}
\usepackage{graphicx}
\newcommand{\minus}{\scalebox{0.75}[1.0]{$-$}}

\begin{document}
  $\minus 16$

  $-16$
\end{document}

where 0.75 is the horizontal scaling of the box. enter image description here

4

enter image description here

I think the normal usage is as in (2) with the normal length minus sign, If used in prefix position TeX does give it closer spacing than when it is used as a binary operator (compare with (1) ).

Using a hyphen as in (3) is just horrible, it's all wrong.

It may depend on national customs but here in the UK for educational use it's customary to distinguish the number -16 from 0 - 16 more clearly so that you can wrote 3 - -16 etc and distinguish the prefix version as part of the number from the infix operator. Using one of (4) or (5) according to taste might be suitable for that usage.

4

If you use the siunitx package, it cares about the right sign and font:

\documentclass[parskip]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage{tgschola}

\usepackage{siunitx}
\sisetup{
   detect-family,
   detect-inline-family=math,
}

\begin{document}
Textmode: \num{-16}

Mathmode: $\num{-16}$

\sffamily
Textmode: \num{-16}

Mathmode: $\num{-16}$

\ttfamily
Textmode: \num{-16}

Mathmode: $\num{-16}$
\end{document}

example

  • When I add \usepackage{eulervm} the first Textmode: \num{-16} is set in Euler. – Jörg Oct 26 '12 at 10:57
  • Not on my system. As far as I know the Euler fonts only use their digits with euler-digits option – Tobi Oct 26 '12 at 11:02
  • As Joseph pointed out above you need detect-mode then. – Jörg Oct 26 '12 at 11:20
0

Look at the following:

\documentclass{article}
\usepackage{times}

\begin{document}
\begin{tabular}{rrrr}
  -16&--16&-$16$&$-16$\\
  +16&+16&+$16$&$+16$
\end{tabular}
\end{document}

comparison of - and --

The hyphen - from the text font (here Times) does not match the +, but the -- does. On the other hand the minus and plus in math mode match one another. And also one may wish to have the minus and plus match in weight the digits. So either do everything in text mode (and use --) or everything in math mode (perhaps with some math font having shorter minus and plus signs if you can find that rarity...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.