# What do empty math character class symbols (“\mathpunct{}”) do, and when are they used?

Every once in a while, one will encounter empty math characters with a specific math character class. For example, amsmath uses \mathpunct{} in its definition of \colon:

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


Let's explore the issue with some tests:

Here is the code that was used to generate this:

\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{mathtools} % for \mathclap
\usepackage[T1]{fontenc} % to disable a warning generated by \textbackslash

\newcommand{\specialcell}[1]{\begin{tabular}[t]{@{}l@{}}#1\end{tabular}}
% for multi-row cells

\begin{document}

\begin{tabular}{lll}
$$abc$$ & \verb|$$abc$$| &  \\[\bigskipamount]
$$a\mathpunct{b}c$$ & \verb|$$a\mathpunct{b}c$$| &
\specialcell{\texttt{\textbackslash mathpunct} will close up to \\
a \texttt{\textbackslash mathord} on the left and \\
create a \texttt{\textbackslash thinmuskip} (\texttt{\textbackslash 3mu}) \\
before a \texttt{\textbackslash mathord} on the right \\[\bigskipamount]} \\
% \verb doesn't work inside of macro arguments, therefore we need \texttt.
% There ought to be a better way of getting the tablerow spacing I want, one that
% doesn't require explicit \\[\bigskipamount] (sometimes placed within the
% \specialcell by necessity).
$$ab\mathpunct{}c$$ & \verb|$$ab\mathpunct{}c$$| &
empty \texttt{\textbackslash mathpunct} \\[\bigskipamount]
$$ab\mathrel{}c$$ & \verb|$$ab\mathrel{}c$$| &
\specialcell{empty \texttt{\textbackslash mathrel}: \texttt{\textbackslash thickmuskip} \\
(\texttt{5mu} (\texttt{plus 5mu})) by default \\[\bigskipamount]} \\
$$ab\mathrel{}\mathrel{}c$$ & \verb|$$ab\mathrel{}\mathrel{}c$$| &
\specialcell{two empty \texttt{\textbackslash mathrel}s are like \\
one empty \texttt{\textbackslash mathrel} \\[\bigskipamount]} \\
$$ab\mathrel{\mathclap{\vert}}c$$ & \verb|$$ab\mathrel{\mathclap{\vert}}c$$| &
\\%[\bigskipamount]
\end{tabular}

\end{document}


(The last line shows that \mathrel{} is like an infinitesimally thin \mathrel with \thickmuskip (\;) spacing on both sides.)

That two successive empty \mathrels are like a single one is just because there is no spacing between any two successive \mathrels. Therefore there is nothing special here.

When might one use "null characters" with specific math character classes? Is there anything important to know?

-

Well you pretty much said what they do in your question, they make a math atom that has zero width, but which may or may not cause math spacing to be added depending on the class of adjacent atoms.

It crops up from time to time eg here

Too small space when using \DeclareMathOperator

And some people use \mathop{} in their definitions of the differential "d" letter:

-

regarding \colon, take a look at the comment in amsmath.pdf just before code line 272:

\colon is for a colon in math that resembles a text colon: small space on the left, larger space on the right. The : character by itself is treated as a \mathrel i.e. large, equal spacing on both sides.

here the \mathpunct dffectively "disables" the usual \mathrel assigned to the character : to allow different spacing to apply.

\mathpunct is also cited, although it does not appear in the code, with respect to the definition of multline, to avoid an extra thinmuskip when punctuation occurs at the end and equation numbers are set on the right. (see the comment after line 2311.)

-