Answering this question: Overlay a 0 with a | I made this code:
\documentclass{article}
\usepackage{tikz}
\newcommand{\zerobar}{
\begin{tikzpicture}[baseline, overlay]
\node[anchor=base] {$0$};
\draw (0,0) -- (0,1.5ex);
\end{tikzpicture}
}
\begin{document}
Test in text \zerobar{} test $0$ test\\
Test in math $\zerobar{}+2=0+2$
\end{document}
How do I make \zerobar behave like 0 with the correct spacing in math?
I was thinking \DeclareMathSymbol, but I am not even sure that it is used for this or that it can be used here. I do not fully understand the examples given here:
https://tex.loria.fr/ctan-doc/macros/latex/doc/html/fntguide/node18.html
or here:
https://cs.brown.edu/about/system/managed/latex/doc/amsfonts.pdf


%from ends of lines – David Carlisle Sep 14 '21 at 21:30overlayhelps, but still not correct. – hpekristiansen Sep 14 '21 at 21:33