[Tex/LaTex] 1.5e-10 style scientific notation looks ugly in LaTeX math mode. How to format it (kerning, etc) more nicely


I've noticed that e-style (for example, 1.5e-10) scientific notation does not look especially nice in Latex math mode:

enter image description here

(code used to generate the above image: $1.5e-10$)

In particular, the width and kerning of the negative sign is totally off. Is there any way to specifically fix the issues with the negative sign?

My LaTeX code:

Here's the complete code, including packages, for the above image:

\usepackage{amsfonts, amsmath, amsthm, amssymb}

I've also run into the exact same kerning issues with MathJax (via the markdown editor in IPython Notebook. Notebook sets MathJax up automatically, so no idea what packages they use).

Context: floating point numbers and numerical programming

For context, when I originally asked this question I was writing a tutorial about the mathematics of stochastic simulation, with the goal of teaching people how to implement their own simulations in Python. This particular notation (<significand>e[<sign>]<exponent>) is relevant since it's how you write a floating point literal (ie a symbol that the Python interpreter understands as representing a particular floating point number). The <signficand>*<base>^<exponent> notation and its prettier variants are less appropriate, since Python (and many other languages) don't recognize it.

Best Answer

It's not ugly, but exactly what's expected. If you type


then you expect that there is some space around the minus sign, because it denotes an operation. When you type $1e-10$, TeX interprets it in exactly the same way, because it can't read your mind: the two expressions are formally the same, only two symbols are different.

If you want that an expression that's normally interpreted as a polynomial should be treated in a different way, then you have to properly mark it.

One solution might be


because in this case the braces around -10 tell TeX to enter a subformula and so the minus sign is initial, so not interpreted as a binary operation, but as a unary operator.

You could make a definition, such as


and input the number as


but there's a much better alternative, the package siunitx.






This package offers many more features than just printing numbers in the desired format; consult its documentation to find them.

enter image description here

Note that siunitx is not understood by MathJax, so with it you must stick to the “hand made” solution. You can still say, in it,


and a formula such as $\num{1e-10}$ will be printed in the way you want.