# Normal ordering macro in LyX

I want to define a macro for the normal ordering of operators as done in this question.

The LaTeX code produced by LyX for this macro is:

\global\long\def\norder#1{\vcentcolon#1\vcentcolon}


However, when I invoke it:

$\norder{\hat{a}\hat{a}^{\dagger}}$


it gives an error:

...ven by $\norder{\hat{a}\hat{a}^{\dagger}}$ The control sequence at the end of the top line of your error message was never \def'ed.

I don't understand why it gives the error. I have more macros in the document and they work perfectly. amsmath and amssimb are loaded through LyX's "Math Options" (and I have checked that I can use commands such as \mathbb inside macros). Looks like the problem is the \vcentcolon command but I don't see why or how to fix it. Thank you!

PS. This is what I have before the begin{document} in the LaTeX source generated by LyX.

\documentclass[english]{article}
\usepackage{mathpazo}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=3cm,lmargin=3cm,rmargin=2cm}
\usepackage{float}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{esint}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{braket}
\makeatother
\usepackage{babel}


The command \ventcolon has not been defined. Load the package mathtools; you can load it instead of amsmath. Moreover, wrap the stuff between the colons into a \mathrel command to improve the spacing.

\usepackage{mathtools}
\newcommand\norder[1]{\vcentcolon\mathrel{#1}\vcentcolon}


\documentclass{article}
\usepackage{mathtools}
\newcommand\norder[1]{\vcentcolon\mathrel{#1}\vcentcolon}
\begin{document}
$A \norder{\hat{a}\hat{a}^{\dagger}} B$
\end{document}

• Adding mathtools solved the issue. Thanks! – VictorSeven May 1 '17 at 15:28