Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a slashed zero symbol in the standard LaTeX font that's accessible with pdflatex et al? I greped through the comprehensive symbols list a bit but didn't spot anything.

In XeLaTeX I can use the OpenType feature +zero on supported fonts. For instance, with Calluna by Exljbris I can do something like this:

\documentclass{minimal}

\usepackage{fontspec}

\newcommand*{\defaultfontfamily}{Calluna}
\setmainfont[Mapping=tex-text]{\defaultfontfamily}
\newcommand*{\lnum}[1]{{\fontspec[RawFeature={+lnum}]{\defaultfontfamily}#1}}
\newcommand*{\zero}[1]{{\fontspec[RawFeature={+zero}]{\defaultfontfamily}#1}}
\newcommand*{\zerolnum}[1]{{\fontspec[RawFeature={+lnum,+zero}]{\defaultfontfamily}#1}}

\begin{document}
0\zero{0}\lnum{0}\zerolnum{0}
\end{document}

and get a few different types of zero:

Several different zeros in Calluna

However, I'd love to find a way to do this in non-OpenType supporting LaTeX engines.

P.S. \(\emptyset\), \(\slashed{0}\), and the like don't count. I'm mostly interested in text mode, but if you have a solution for text mode and math mode that would be nice too. Also, before someone says it, \o and \O are letters, not numbers. They don't count either!

share|improve this question
2  
What do you mean by “the unicode feature +zero”? The OpenType font feature zero, I presume; it is not part of Unicode but of OpenType. When supported, it simply selects a slashed glyph for digit 0, when available in a font. When the feature is not available, you would need to use a font where the normal glyph for digit 0 is slashed – or to use some technique that lays a slash over digit 0. –  Jukka K. Korpela Sep 13 '13 at 4:51
    
Yah, sorry, I meant OpenType; fixed. –  Sam Whited Sep 13 '13 at 13:50
1  
You can of course define your own 8-bit fonts with these features with the help of otftotfm or such and switch to these fonts. –  Martin Schröder Sep 13 '13 at 14:01
    
@MartinSchröder Thanks for that link; oddly enough, I hadn't considered just taking an existing font and converting it if the default font didn't have one (which it apparently doesn't). That may end up being my final solution. –  Sam Whited Sep 13 '13 at 14:02
    
@SamWhited: Use LuaLaTeX instead. :-) –  Martin Schröder Sep 13 '13 at 14:03

4 Answers 4

up vote 7 down vote accepted

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{}.

share|improve this answer
    
Thanks; this is the second best thing to actually just having that feature available in the font! Thanks for putting in the time/effort to correct the alignment and boldface issues as well; this is one of the reasons I was asking (trying to do it myself and I ran into issues like this). Will leave this open a bit longer, then probably will accept this as the answer. –  Sam Whited Sep 13 '13 at 14:04
    
another possibility is to inject a small 45-degree slash into the zero. \smallsetminus (amsfonts) is the general idea, but it slants in the wrong direction. an article, "oh, oh, zero", by chuck bigelow in the latest issue of tugboat (34:2, pp.168-181) examines the history of this topic, but is accessible only to tug members until september 2014. –  barbara beeton Oct 8 '13 at 15:24
    
@barbarabeeton: The wrong direction of \smallsetminus of package amssymb can be cured by \reflectbox or \rotatebox{90}. But 45 degree is too small, because the height of 0 is larger than its width. The latter is not even known because of the side bearings. Also the character box of \smallsetminus is not regular, thus it is not known at TeX level, where the line starts and ends. –  Heiko Oberdiek Oct 9 '13 at 6:45
    
@HeikoOberdiek -- i think you misunderstood what i meant about the shape. in the article i mentioned by chuck bigelow is an example of the zero with the small slash. it is attributed to lucida grande (example on p.171 of the article). the slash doesn't go to the top or bottom of the zero, but extends vertically only through the middle third, touching the sides but not extending beyond them. i'll try to cut-and-paste an example into a "minimal" answer. –  barbara beeton Oct 9 '13 at 13:01

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

\documentclass{arlticle}
\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

share|improve this answer
    
Thanks, I'll give that a shot; I think Heiko's solution might be a bit more robust (in the general sense, not the TeX sense) and doesn't require another package, but this is a lot simpler. Definitely good to have both! –  Sam Whited Sep 13 '13 at 14:05
    
@SamWhited Glad to help. I should have explained the syntax, since the \stackinset macro was introduced in this week's package revision. The two c chars indicate the inset is measured relative to the x and y vertical "centers" of the anchor (the 0), and the two blank arguments mean that the inset character (the /) is unshifted in x and y relative to the c,c origin of the anchor. –  Steven B. Segletes Sep 13 '13 at 21:31

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

share|improve this answer
    
Are all zero's slashed in that font, or do you have to do something to enable this? I'd rather use a font like this where appropriate than hack something together like the other answers (though it's good to have both solutions available). –  Sam Whited Oct 9 '13 at 13:15
    
@SamWhited -- according to the (scanty) information in the article, this slashed zero is the base form; there is also an "empty" zero and one with a dot. the name of the font as given in the example is "lucida grande 1450". it's a sans serif font, as are all other fonts with this form of zero. looking further at the article (p.173), i see (short-)slashed zeros in monaco, consolas, inconsolata, and lucida retro, all monospace fonts. these fonts tend to be special-purpose, but digits are usually less "special" than letters of the alphabet. –  barbara beeton Oct 9 '13 at 13:31
    
Good to know; thanks. I'll check that article out as soon as it becomes available to the general public. –  Sam Whited Oct 9 '13 at 14:08

Some of the font packages I've made include a command enabling access to the slashed zero where this is available. For example for the Latin Modern fonts:

\documentclass{article}
\usepackage{cfr-lm}
\begin{document}
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \bfseries
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \mdseries\sffamily
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash

    \bfseries
    0123456789\zeroslash

    \tostyle
    0123456789\zeroslash

    \plstyle
    0123456789\zeroslash

    \tlstyle
    0123456789\zeroslash
\end{document}

berenisadf also offers the slashed zero.

Generally, my packages should enable access to variant zeros where they are available in the fonts. (I don't attempt to fake this, so the availability is entirely dependent on what the font includes.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.