5

This question explains how to make : behave as \colon. Except that the solution in the most upvoted answer doesn't work 100%. That solution says to make : behave in such a way, one has to use the command \DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}.

With that command it looks like this (how it looks for \colon was added as an optical reference):

enter image description here

So one can see, that the :, although it should look like \colon actually has the spacing a bit different. Question 1: Is there a way to fix this ?

For completeness, this is how it looks, when the above command is disabled, and : is displayed as it normally would:

enter image description here

Question 2: Does activating this option change in any way the spacing of : when it is not used in math mode?

l7ll7
  • 2,267

1 Answers1

7

In a minimal document there is no difference:

Sample output

\documentclass{article}

\usepackage{amssymb}
\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}

\begin{document}

\( f\colon \mathbb R \to \mathbb R \)

\( f: \mathbb R \to \mathbb R \)

\end{document}

However if you load amsmath then the difference you describe does occur:

Ams sample

\documentclass{article}

\usepackage{amssymb,amsmath}
\DeclareMathSymbol{:}{\mathpunct}{operators}{"3A}

\begin{document}

\( f\colon \mathbb R \to \mathbb R \)

\( f: \mathbb R \to \mathbb R \)

\end{document}

The reason is that the definition of \colon is changed in amsmath to

\renewcommand{\colon}{\nobreak\mskip2mu\mathpunct{}\nonscript
  \mkern-\thinmuskip{:}\mskip6muplus1mu\relax}

giving greater spacing. Thus the simple redefinition of the other answer is not sufficient. You need to use the more complicated version provided by egreg there instead; his solution loads mathtools which loads amsmath.

As regards your second question: no, neither of the solutions to the other question affect colons outside of math mode.

Andrew Swann
  • 95,762
  • Thanks for your good explanation. Before I accept your answer, could you please also answer question 2 ? And could you please tell me, which version of : should be used when defining functions as above for most professional looking documents: The one where Carlisle's redefinition changes :, the one with \colon or the standard : ?

    Also, if you're interested, your answer generated a follow-up question, http://tex.stackexchange.com/questions/264401/is-set-to-colon-but-the-spacing-is-still-wrong-part-2, which pertains to :=, as egregs answer also has his rough corners.

    – l7ll7 Sep 02 '15 at 15:51
  • I would say the AMS (= American Mathematical Society) definition is the better one for spacing. – Andrew Swann Sep 02 '15 at 16:27
  • So you mean the use of \colon (or a redefinition of : that looks like that) is best ? Could you please answer question 2 ? – l7ll7 Sep 02 '15 at 16:30
  • Yes - the AMS use this for professional typesseting of their journals. 2. Done.
  • – Andrew Swann Sep 02 '15 at 16:42