How to typeset ::= correctly [duplicate]

How can I typeset the equality symbol ::= used in the definition of syntactic categories of BNF grammars?

I would like to use it both in typewriter font (using \texttt) and in math mode.

Both \texttt{::=} and $::=$ (or $:\coloneqq$) are ugly.

marked as duplicate by Henri Menke, Troy, Kurt, TeXnician, Stefan PinnowMay 20 '18 at 15:54

• Have you tried $\operatorname{::=}$ in math mode, it looks a little bit better maybe? – RockyRock May 20 '18 at 11:44
• Another version is $\Coloneqq$from the package \usepackage{txfonts} as well as others here – RockyRock May 20 '18 at 11:54

Like this?

\documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\newcommand{\Coloneqq}{\mathrel{\vcenter{\hbox{$:$}}{\coloneqq}}}

\begin{document}

$A \Coloneqq B$

\end{document}


• Thanks! I looked up for that symbol in the Comprehensive LaTeX Symbol List but I wasn't able to find it out. Also detexify didn't help (don't know if it was for my poor drawing skill or if it is not aware of that symbol). – BlackBrain May 24 '18 at 9:10