Spacing in math mode
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} $
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
).
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}$