61

I've occasionally seen a negative (when a number is simply negative, not a subtraction), typeset as negative sign that's slightly skinnier and above the centre line of text. Is this proper notation for mathematics and how would one go about typesetting this in LaTeX?

Edit

I believe that calculators were what happened to give me this idea, couldn't find it in any of my math books. Thank you all for the help, it's much appreciated.

alt text

Thank you 'Antal S-Z' for the photo link.

However, the question remains, how exactly would I typeset this?

8
  • 2
    Perhaps an example of the kind of symbol you're interested in would help...
    – Seamus
    Oct 31, 2010 at 21:09
  • I've never seen this (but of course that doesn't mean it doesn't exist). Unicode has only one "minus" character, too. So I agree with Seamus: please give an example.
    – Philipp
    Oct 31, 2010 at 21:49
  • 3
    I have seen this only in one situation: my kids regularly bring home from school math homework sheets that use this kind of notation. It seems that some math educationists believe that it is less confusing for kids if they use different symbols the binary operation of subtraction than for the unary operation of opposite. I have never seen it anywhere else. The symbol they use on the worksheet is so small and thin that it is almost invisible on the xerox copies the kids bring home. Nov 1, 2010 at 2:49
  • @Seamus, see the edit. I believe this is in fact what sparked my memory, I can't seem to find any similar notations in my piles of math books, but it makes sense why they did what they did. Antal S-Z below in a comment linked this photo and it seems to be what was driving my memory of that.
    – EricR
    Nov 1, 2010 at 2:55
  • 3
    I've always seen this as the calculator programmers being too lazy to write a parser that can handle - as both a unary and a binary operator.
    – asmeurer
    Sep 8, 2013 at 19:57

9 Answers 9

47

My understanding is that a negative sign is the same as a minus sign, but the spacing is different since it's a unary operator rather than a binary operator. You can see this in TeX: $-x$ has different spacing from $y-x$:

I'm not sure I can answer your question about it being proper, but I'll say that I've never seen mathematics typeset with a raised, smaller negative sign. (But take that with a grain of salt because most, but not all, math I read is typeset with LaTeX.)

6
  • 1
    hmmm. sure I've seen people write $0^-$ or $0^+$, but not a preceding raised smaller minus sign. Oct 31, 2010 at 21:51
  • @Yossi Farjoun: I think the OP and TH. meant slightly raised with respect to vertical centre as opposed to a superscript. Oct 31, 2010 at 23:03
  • 2
    @Willie: Indeed. I seem to recall that my TI-8x calculator distinguished the symbols as the OP described, but I don't have batteries for it to check
    – TH.
    Nov 1, 2010 at 0:17
  • Now that you mention it, my TI-84+ does/did exactly that; this screenshot of what seems to be an emulator is an example. And SML uses ~3 for negative three, and 3-4 for three minus four, though that's driven out of a desire to avoid ambiguity. Nov 1, 2010 at 2:47
  • @All, thinking of it, my TI-84+ may be precisely what sparked my memory.
    – EricR
    Nov 1, 2010 at 2:53
91

If latex gives you a binary minus and you want the unary minus (i.e. negative), just add curly braces around the expression, e.g. change -x to {-x}. See post #4 at mathhelpforum

2
  • 12
    This is very helpful for instance in Miller index notation [1 {-1} 1] in crystallography.
    – strpeter
    Dec 30, 2013 at 13:00
  • Also +1. This is helpful when I wanted to keep a negative sign in front of an expression that was being differentiated (using a differentiation operator). It helped intuition to write it this way. Latex thought I was subtracting my expression from d/dx :)
    – AdamO
    Nov 16, 2014 at 20:58
13

Here is an example, but you still have to distinguish between unary and binary minus manually:

\documentclass{minimal}

\usepackage{xparse}

\makeatletter
\NewDocumentCommand{\raisedminus}{m}{%
  \raisebox{0.2em}{$\m@th#1{-}$}%
}
\NewDocumentCommand{\unaryminus}{}{%
  \mathbin{%
    \mathchoice{%
      \raisedminus\scriptstyle
    }{%
      \raisedminus\scriptstyle
    }{%
      \raisedminus\scriptscriptstyle
    }{%
      \raisedminus\scriptscriptstyle
    }%
  }%
}
\makeatother

\begin{document}

$\unaryminus 3 - 4$

\end{document}

output

3
  • I don't think you want a \mathbin since it isn't a binary operator. \mathord seems more appropriate. (I think that boxes are normally set with ordinary spacing so nothing is actually needed.)
    – TH.
    Nov 1, 2010 at 9:53
  • 1
    In this case it doesn't actually matter because the Bin atom is converted to an Ord atom at all places where it is reasonable. (That is how the normal minus works, after all.)
    – Philipp
    Nov 1, 2010 at 10:12
  • thank you. This works exactly as I would expect it to. Cheers.
    – EricR
    Nov 1, 2010 at 13:52
8

I'll throw in a few thoughts to answer the part "Is this proper notation for mathematics" of the question. First of all: No, it's not proper. One reason, as others have observed before me: It's just never used, except in school textbooks where they have to distiguish two different keys on the calculator keyboard. So, if you type a manual for a calculator, you can use Philipp's \unaryminus. (And otherwise you shouldn't use it.)

The second reason: Try to use the symbol in handwriting. Will you really manage to write it in a way that it is always clear which of two minus symbols is meant? At least I wouldn't. I think this is one of the reasons why in mathematics there is just this one minus sign.

What I can't answer is why they have two different keys on the calculator. Maybe it was for simplifying the programming in the early days, or it's for didactic reason; I don't know.

9
  • for your second reason, there are differences between em dash and en dash even though those are hard to distinguish when written by hand.
    – momeara
    Apr 3, 2012 at 17:08
  • 3
    A comment by an anonymous user: "don't know for what reason it was introduced on the TI and other calculators, but as someone who works with low-performing remedial students, I can say that introducing the distinction is a pedagogical nightmare. It actually makes it more difficult for these students to grasp that 3 + -4 is the same as 3 - 4."
    – topskip
    Jun 28, 2012 at 9:40
  • (see suggested edit) Jun 28, 2012 at 9:57
  • 1
    For the record, this bit of pedagogy does exist independently of calculators. I learned this notation in secondary school in a year when graphing/programmable/etc calculators existed but were uncommon. (The class was in French, which may or may not be correlated with this notational convention.) Nov 1, 2013 at 23:19
8

Here is a LuaLaTeX approach that discovers unary minuses automatically (but the \raisebox doesn't work for a reason I don't understand):

\documentclass{minimal}

\usepackage{luatextra}
\usepackage{xparse}

\makeatletter
\NewDocumentCommand{\raisedminus}{m}{%
  \raisebox{0.2em}{$\m@th#1{-}$}%
}
\makeatother

\newsavebox{\scriptraisedminus}
\sbox{\scriptraisedminus}{\raisedminus{\scriptstyle}}
\newsavebox{\scriptscriptraisedminus}
\sbox{\scriptscriptraisedminus}{\raisedminus{\scriptscriptstyle}}

\begin{luacode}
local unary_minus = node.new(15)
unary_minus.display = node.new(16, 0)
unary_minus.display.nucleus = node.new(32)
unary_minus.display.nucleus.list = node.copy_list(tex.getbox(\number\scriptraisedminus))
unary_minus.text = node.new(16, 0)
unary_minus.text.nucleus = node.new(32)
unary_minus.text.nucleus.list = node.copy_list(tex.getbox(\number\scriptraisedminus))
unary_minus.script = node.new(16, 0)
unary_minus.script.nucleus = node.new(32)
unary_minus.script.nucleus.list = node.copy_list(tex.getbox(\number\scriptscriptraisedminus))
unary_minus.scriptscript = node.new(16, 0)
unary_minus.scriptscript.nucleus = node.new(32)
unary_minus.scriptscript.nucleus.list = node.copy_list(tex.getbox(\number\scriptscriptraisedminus))

function is_bin_conv_to_ord(v, p)
  if not v or v.id \string~= 16 or v.subtype \string~= 4 then return false end
  if not p then return true end
  if p.id == 16 and ((p.subtype >= 1 and p.subtype <= 6) or p.subtype == 8) then return true end
  local n = v.next
  if q and q.id == 16 and (q.subtype == 5 or q.subtype == 7 or q.subtype == 8) then return true end
  return false
end

function replace_unary_minus(head, displaytype, need_penalties)
  local p = nil
  local v = head
  while v do
    if is_bin_conv_to_ord(v, p) then
      local n = v.nucleus
      if n and n.id == 31 and n.fam == 2 and n.char == 0 then
        node.insert_after(head, v, node.copy(unary_minus))
        head, w = node.remove(head, v)
      end
    end
    p = v
    v = v.next
  end
  return node.mlist_to_hlist(head, displaytype, need_penalties)
end

luatexbase.add_to_callback("mlist_to_hlist", replace_unary_minus, "replace_unary_minus")
\end{luacode}

\begin{document}

$-3 - 4$

\end{document}

output

1
  • This does not work with current LuaTeX 1.07.0 (You cannot set field display in a node of type unset). Probably many of the magic numbers have changed. Unfortunately, I have no idea what node ID 15 was, back when this answer was posted. Today, node.new also accepts the ID as a string, e.g. node.new("noad"). Apr 19, 2018 at 11:08
4

I think it is a nice question, but...

The minus on the TI-84 as a negative number can be used in the input without brackets... So you can type: 3 + -5 and the calculator will not make a problem of it. But if you type 3 + -5 as a minus, than the calculator will jump to the error "-". (same for 3*-5=-15 and 3* "-"5 gives an error.

In order to show you the error on the calculator, there is a difference between the 2 characters on a calculator.

I don't see any reasons to make that difference in typing. Like said above... you don't make a difference in handwriting, why should you make it complex (and I dont mean complex numbers :-) in typing.

Let's go for the KIS method... Keep it simple.

As a bonus the code for TI-84 buttons

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancybox}
%%FOR TI 84 buttons
\newcommand{\btb}[1]{\ovalbox{\rule[-0.5ex]{0pt}{2ex}{\tt #1}}}
\newcommand{\sel}[1]{{\tt [#1]}}
\newcommand{\bt}[1]{\btb{#1}\index{{\tt [#1]}}}
\newcommand{\sbt}[1]{\btb{2nd}{\sel{#1}}}
\newcommand{\abt}[1]{\btb{alpha}{\sel{#1}}}
\begin{document}
\begin{itemize}
    \item   \bt{3} \bt{+} \bt{-} \bt{5} \bt{=} \bt{-2}
    \item \bt{3} \bt{+} \bt{$-$} \bt{5} \bt{=} SYNTAX ERROR
\end{itemize}
\end{document}

enter image description here

2

I don't see this as a unary operator but more of a typesetting property of negative numerical values. Or as @tohecz pointed out in his comment to another answer:

the unary minus is a "part of the numeral"

In other words, the symbols "-" in "-3" and "-x" are unrelated typographically.

In light of this, I propose this solution. Which is very elegant if you get to the habit of using \num (from siunitx package) around all your numerical literals:

\documentclass{article}
\usepackage{siunitx}
\sisetup{bracket-negative-numbers, open-bracket={
    {}^-% your custom hack here
}, close-bracket={}}

\begin{document}
\noindent
\num{-1}\\
\num{1}\\
\num{-1e3}\\
\num{1e-3}\\
$\num{-3} - \num{4}$\\
$[\num{1}\,\num{-1}\,\num{1}]

\end{document}

minusnotation

Note: I don't particularly advocate for using {}^-, this seems quite extreme. It is just an example to show the difference and I didn't want to clutter the answer with more code. What I advocate is the use of siunitx for fine control over typesetting of numbers.

Besides I wanted to have a code that works also for superscripts (for the exponent) (using hard code raisebox produces weird effects on exponents or small fractions). If know of a short code that can do this elegantly please edit this answer.

2

I bumped into the same problem when subindexing letters with negative numbers. The "math minus" looks to me too long. Therefore I write a "text minus", i.e., \text{-} before the number. It is quite similar to the solution of @Arne Timperman: his is from text modus, mine from math modus.

subindex with minus math and text

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$A_{2\,1\,-1}$ %math minus, a bit excessively long for my taste ;).

$A_{2\,1\,\text{-}1}$ %text minus, in this case looks better.
\end{document}
-2

I've seen it done by simply superscripting the minus sign, i.e. ^- giving e.g.:

\documentclass{article}
\begin{document}
$^-3-4=^-7$
\end{document}

I wouldn't use it routinely, only when it's important to distinguish the two, as when defining negative numbers and how subtraction interacts with them (in arithmatic).

EDIT to my surprise, tex.stackexchange.com doesn't interpret $...$ as latex, unlike e.g. math.stackexchange.com. I guess because it could only support a very limited subset.

EDIT It's good that I tried an actual example, because it renders with extra spacing between the - and 7, but not between the - and 3. I don't know why.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .