Inserting slashed zero in non-OpenType supporting LaTeX

The following example defines poor man's versions of a zero with dot (\pmzerodot) and slash (\pmzeroslash).

Remarks for \pmzerodot:

  • \cdot is used as the dot. Normally it is placed on the math axis that does not have to be the vertical middle of the digit zero. Therefore the height of the digit is measured and the dot is placed in the middle.
  • For slanted fonts, the italic correction for the digit zero is taken into account for a better horizontal placement of the dot.
  • \cdot is used in math mode. This makes a visible difference for bold text fonts. If the font series (\f@series) starts with b, then \mathversion{bold} is used for the dot.

Remarks for \pmzeroslash:

  • The slash is centered vertically around the middle of digit zero.
  • Using the text version of the slash has the advantage that the symbol is taken from the same font as the digit.

Example file:

\documentclass{article}

\makeatletter
\newcommand*{\pmzerodot}{%
  \nfss@text{%
    \sbox0{$\vcenter{}$}% math axis
    \sbox2{0}%
    \sbox4{0\/}%
    \ooalign{%
      0\cr
      \hidewidth
      \kern\dimexpr\wd4-\wd2\relax % compensate for slanted fonts
      \raise\dimexpr(\ht2-\dp2)/2-\ht0\relax\hbox{%
        \if b\expandafter\@car\f@series\@nil\relax
          \mathversion{bold}%
        \fi
        $\cdot\m@th$%
      }%
      \hidewidth
      \cr
      \vphantom{0}% correct depth of final symbol
    }%
  }%
}
\newcommand*{\pmzeroslash}{%
  \nfss@text{%
    \sbox0{0}%
    \sbox2{/}%
    \sbox4{%
      \raise\dimexpr((\ht0-\dp0)-(\ht2-\dp2))/2\relax\copy2 %
    }%
    \ooalign{%
      \hfill\copy4 \hfill\cr
      \hfill0\hfill\cr
    }%
    \vphantom{0\copy4 }% correct overall height and depth of the symbol
  }%
}
\makeatother

\usepackage{amstext}% for resizing the symbol in math

\begin{document}

  \newcommand*{\teststring}{0\pmzerodot\pmzeroslash}

  \teststring

  % check symbol bounding boxes
  \setlength{\fboxsep}{0pt} 
  \setlength{\fboxrule}{.1pt}
  \fbox{0}\fbox{\pmzerodot}\fbox{\pmzeroslash}

  % test different fonts

  \textsf{\teststring}

  \texttt{\teststring}

  \textbf{\teststring}

  \textit{\teststring}

  % math test
  $\teststring^{\teststring^{\teststring}}$

\end{document}

Result

Remarks:

  • The symbols are wrapped in \nfss@text. It is defined by the LaTeX kernel as \mbox inside a group. Package amstext (loaded by amsmath) redefines it as \text that allows that the symbols can be automatically resized in math mode.

  • \ooalign only keeps the height of the first line and the depth of the final line. \vphantom is inserted to get the correct overall height and depth of the symbol.

  • \m@th avoids additional horizontal spacing, if \mathsurround is used.

  • The height of the math axis is available by the height of an empty \vcenter{}.


The stackengine package allows you to overlay glyphs. It works in both math mode and text mode.

\documentclass{article}
\usepackage{stackengine}[2013-09-11]
\newcommand\slashzero{\stackinset{c}{}{c}{}{/}{0}}
\begin{document}
In text mode \slashzero\ and in math mode: \( A = \slashzero \)
\end{document}

enter image description here


this is not a full answer, but it's the only way i know to include a picture.

this slashed zero exists in lucida grande; the image is cropped from the article "oh, oh, zero!" by chuck bigelow, in the current issue of tugboat (34:2, pp.168-181); this glyph appears as an example on pages 168 and 171. (the article is currently accessible only to tug members, but should become generally available in september 2014.)

slashed zero from the lucida grande font