10

In Math mode, if I write ":", it will automatically insert spaces before and after the colon. For example, $s:type$ will be shown as "s : type". How can I remove these spaces?

11

Add a pair of brackets around the colon, and put type inside a \text command. Alternatively, you can use \colon which looks better, in my opinion:

$ \begin{array}{l}
     s: \text{type}\\
    s{:}\text{type} \\
     s\colon \text{type}
\end{array} $

enter image description here

8

The colon : is declared by LaTeX as a binary relation, which means it is separated from ordinary symbols by a thick mathematical space.

The \colon command makes a punctuation symbol, so no space before it and a medium math space after it. However amsmath slightly changes colon to have some space before it and some more than a punctuation symbol after it.

You can make any character into another math atom by using an “atom declaration”: thus \mathbin{:} would make the colon into a binary operation symbol (spaced like +); with \mathord{:} you get an “ordinary atom”, like a letter. Also \text{...} makes an ordinary atom so

s\mathord{:}\text{type}

is what you probably want. However, \mathord{:} can be abbreviated into {:}, because TeX treats as an ordinary symbol any subformula inserted in a pair of braces (provided they don't delimit the argument to a command).

Beware, though that \text{type} might produce the text in italics if the formula is inside the statement of a theorem. Better doing something like

\newcommand{\foo}[1]{\textnormal{#1}}

in the preamble and type the formula as

s{:}\foo{type}

(choose a better name than \foo).

3

If you are going to use this for other things, may be the best would be to make a macro

\newcommand*\type[1]{#1\mathord{:}\textnormal{type}}
$\type{s}$ 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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