13

Example

\documentclass[a4paper,11pt,border=1pt]{standalone}
%\LetLtxMacro{\oldcdot}{\cdot}
%\renewcommand{\cdot}{\!\cdot\!} <-- Like this
\begin{document}
$3\cdot 10^8$ m/s
\end{document}

I'm getting the following output.

enter image description here

However \cdot has many spaces between left and right. How do I get the following image? Should I have a macro?

enter image description here

Related to: https://tex.stackexchange.com/a/29838/33075

Özgür
  • 3,270

2 Answers2

16

For this I recommend siunitx, that ensures uniformity in numbers and units.

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}

\sisetup{
  exponent-product={{\cdot}}, % double brace for avoiding the space
  per-mode=symbol,
}

\begin{document}

\SI{3e8}{\meter\per\second} % long form

\SI{3e8}{m/s} % abbreviated form

\SI[per-mode=reciprocal]{3e8}{\meter\per\second} % long form

\end{document}

Note that it's easy to change from a representation to another, when the long form is used (which is recommended).

Also this has the advantage that you just need to change the option in the preamble if you change your mind about how to represent that product.

enter image description here

The same effect can be obtained with the option tight-spacing, which however will act also on all binary operations, for instance uncertainties.

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}

\sisetup{
  exponent-product=\cdot,
  tight-spacing,
  per-mode=symbol,
}

\begin{document}

\SI{3e8}{\meter\per\second} % long form

\SI{3e8}{m/s} % abbreviated form

\SI[per-mode=reciprocal]{3e8}{\meter\per\second} % long form

\end{document}
egreg
  • 1,121,712
  • 1
    Now this is the proper way to do it :-) – Phelype Oleinik Apr 18 '19 at 16:52
  • 2
    +1. Instead of hard-coding the tightly-spaced behavior, one could also run \sisetup{exponent-product=\cdot, tight-spacing=true}. Then, if at some point in the document it becomes necessary to switch to non-tight spacing, one can simply execute \sisetup{tight-spacing=false}. – Mico Apr 18 '19 at 17:29
  • @Mico Thanks for the hint. I added it, but noted that this acts also in other places. – egreg Apr 18 '19 at 22:18
15

\cdot is defined in fontmath.ltx with:

\DeclareMathSymbol{\cdot}{\mathbin}{symbols}{"01}

which means it is a binary operator (\mathbin) so it will have an extra space before and after as other binary operators, such as + and -.

TeX will not insert that space if you “hide” \cdot within braces:

\documentclass[11pt,border=1pt]{standalone}
\begin{document}
$3{\cdot} 10^8$ m/s
\end{document}

If you will use that symbol multiple times you can define an ordinary math symbol (\mathord) with the same glyph as \cdot:

\documentclass[11pt,border=1pt]{standalone}
\DeclareMathSymbol{\mdot}{\mathord}{symbols}{"01}
\begin{document}
$3\mdot 10^8$ m/s
\end{document}

or you can redefine \cdot with the same command.

  • 1
    +1 Or call it \mdot for "multiplication dot" – Andrew Swann Apr 24 '19 at 06:08
  • I largely prefer this answer since it addresses the general case of spacings before and after \cdot which IMHO are way too large (and mostly encourages one to just put several characters together without \cdot between them, e.g. 2jk\pi instead of 2 \cdot j \cdot k \cdot \pi, which is - I believe - quite bad practice). Anyway, the simple \DeclareMathSymbol{\cdot}{\mathord}{symbols}{"01} did the trick for me. Thanks! :) – mranvick May 17 '22 at 07:46