Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following.

\item Arrange in ascending order (smallest to largest): $−6, −2, 0, 1, −5, 4, 3$

But this output does not have negative signs.

6, 2, 0, 1, 5, 4, 3

It shows negative in other places.

\item Evaluate $(-2)^2$

This output has a negative sign.

Evaluate (−2)2

What am I doing wrong here?

Thank you in advance.

share|improve this question

2 Answers 2

up vote 9 down vote accepted

The minus signs in $−6, −2, 0, 1, −5, 4, 3$ are not hyphens - (0x2d) but dashes (0x2212). A dash is slightly longer than a hyphen.

Solution: Replace dashes with hyphens.

The minus sign in \item Evaluate $(-2)^2$ is already a hyphen.

share|improve this answer
2  
Note that \usepackage{lmodern} is extremely illuminating in this respect! –  cfr Apr 11 at 3:03
2  
Thanks. It happened so because I copy and paste it from MS Word. –  shin Apr 11 at 3:05
    
@shin That warning is good to know, re: MS Word. –  Steven B. Segletes Apr 11 at 3:47
1  
The advice is correct but note that U+2212 isn't a "dash" it is "MINUS SIGN" so typographically it's the correct character, so in unicode-math it should work, but for classic tex, as you say you should use - just as you should use ` and ' rather than typographical left and right qutes as TeX input. –  David Carlisle Apr 11 at 6:52

If you're doing much copy-paste from word processors, then it's better to load

\usepackage[utf8]{inputenc}

in your LaTeX document. Then you can teach LaTeX new correspondences between Unicode characters and LaTeX set of known objects, in this case

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}

%% the first is the “unknown minus” (U+2212), the second is a hyphen
\newunicodechar{−}{-}

\begin{document}
$−1$
\end{document}

How do you know there's something amiss? Look in the .log file: you should find several instances of something like

Missing character: There is no <E2> in font cmr10!
Missing character: There is no <88> in font cmr10!
Missing character: There is no <92> in font cmr10!

one for each “disappearing” minus sign. Indeed, if you don't load inputenc with the utf8 option, TeX just sees the three byte representation of U+2212, precisely the bytes 0xE2, 0x88 and 0x92 that don't correspond to a printable character, because the default TeX fonts have only 128 glyphs.

With utf8, but no \newunicodechar declaration you'd get an error:

! Package inputenc Error: Unicode char \u8:− not set up for use with LaTeX.

and you can so understand what went wrong: the minus sign is not understood. Copy it and use it for defining the correct \newunicodechar declaration.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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