Math-Mode Symbols Overlays – Overlay a 0 with a |

math-modeoverlayssymbols

How can I overlay a 0 with a | in latex to create a new symbol comprised of a 0 with a vertical line inside it?enter image description here

I've looked at the following post Overlay symbol with another and tried to adapt the code provided in one of the answers, because I didn't understood the accepted answer, but this did not output the symbol that I wanted.

\newcommand\cz{\mathrel{\ooalign{$|$\cr\hidewidth$0$\hidewidth\cr}}}

The vertical dash would go out of the zero and when I wrote another letter next to this symbol the spacing would be incorrect. In order to try and understand the accepted answer I tried to look for the commands used there, like \rlap, \setbox, …, in the web and in the latex reference provided with texmaker under the help tab but the web pages I found explainde very poorly these commands and the latex refence didn't even had them. Where can I find the official documentation for these commands or any other good resource to learn them?

Best Answer

Made to work in all math styles. I overlay a stretched \vert inside a 0.

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\vertzero{\ThisStyle{\ensurestackMath{\stackengine
  {0pt}{\SavedStyle0}{\SavedStyle\stretchrel*{\vert}{0}}%
  {O}{c}{F}{F}{L}}}}
\begin{document}
$\vertzero\scriptstyle\vertzero\scriptscriptstyle\vertzero$
\end{document}

enter image description here

If one did not like seeing, under high magnification, the rounded extrema of the \vert, one could tweak it as

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\vertzero{\ThisStyle{\ensurestackMath{\stackengine
  {0pt}{\SavedStyle0}%
  {\SavedStyle\stretchrel*{\vert}{\addstackgap[.1\LMpt]{\SavedStyle0}}}%
  {O}{c}{F}{F}{L}}}}
\begin{document}
$\vertzero\scriptstyle\vertzero\scriptscriptstyle\vertzero$
\end{document}

enter image description here

If one wanted more control over the width of the bar, replacing the \vert with a \rule of specified width would provide that flexibility. Here, I make the width .6\LMpt, where \LMpt is a measure of pt that is scaled in the smaller math styles.

\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\vertzero{\ThisStyle{\ensurestackMath{\stackengine
  {0pt}{\SavedStyle0}{\SavedStyle\stretchrel*{\rule{.6\LMpt}{1ex}}{0}}%
  {O}{c}{F}{F}{L}}}}
\begin{document}
$\vertzero\scriptstyle\vertzero\scriptscriptstyle\vertzero$
\end{document}

enter image description here