4

According to oeis.org, I should be able to write the symbols for the integers like so: \Z. However, this doesn't work. Here is my LaTeX file:

\documentclass{article}\usepackage{amsmath}
\begin{document}
$\mathcal {P} (\mathbb{Z})$
\Z
\end{document}

I have also tried following this question. However, again, no luck. Here is my code:

\documentclass{article}\usepackage{amsmath}
\begin{document}
$\mathbb{Z}$
\end{document}

I suspect I need to import a package. However, I don't know which, and none of the sources I have mentioned seem to refer to a package I need to import. How should I proceed?

  • \mathbb is defined in the package amsfonts. I have no idea where \Z et al. may be defined, and the linked page isn't helpful. – barbara beeton Jan 24 at 20:28
  • 5
    Some varieties of MathJax define \Z to yield \mathbb{Z}, but there is no such definition in standard LaTeX. You need to load amssymb (or just amsfonts). – egreg Jan 24 at 20:33
  • 1
    Incidentally, you should not blindly trust the information stated on the oeis.org site. In fact, much of what's stated on that site is badly in error. For example, it says that in order to write A, B, and E in math mode, one can do so by writing \Alpha, \Beta, and Epsilon. And, to give just another example, there's a claim that + and - are unary operators. That's just wrong: by default, TeX treats them as binary operators. However, TeX has clever rules in place to adjust the spacing around the symbols if they're used as unary operators. – Mico Jan 25 at 9:02
9

Some general comments and observations:

  • Assuming you use pdfLaTeX to compile your document, then unless you either load a font that natively provides "blackboard bold" (aka "double-struck") uppercase letters or load some other package which loads a suitable math font, you will need to load the amsfonts package in order to access the \mathbb macro.

  • Loading the amssymb package "works" too, since amssymb loads amsfonts automatically.

  • The pdfLaTeX kernel does not provide commands named \N and \Z by default. (Aside: I have no idea why the website you provide a link to claims that one can use \N directly in a LaTeX document.) However, as is shown below, it's rather straightforward to create macros named \N and \Z which, in turn, execute \mathbb{N} and \mathbb{Z}, respectively. (Or, if you prefer, load the dsfont package and define \N, say, via \newcommand{\N}{\mathds{N}}.)

  • If you can use either LuaLaTeX or XeLaTeX to compile your document, you may want to load the unicode-math package to get access to its \symbb macro. This lets you create double-struck characters not just for uppercase letters but for lowercase letters and numerals as well. An example: $\symbb{ABCabc123}$. A

The test program used to create the following screenshot employs pdfLaTeX and shows the symbols frequently used to denote the sets of integers ("Natürliche Zahlen" in German), whole numbers ("ganze Zahlen"), rational numbers, real numbers, and complex numbers.

enter image description here

\documentclass[border=1pt]{standalone} 
\usepackage{amsfonts} % for "\mathbb" macro
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}

\begin{document}
$\N \quad \Z \quad \Q \quad \R \quad \C$
\end{document}
  • 3
    In Addition to Mico's answer I would like to offer the command \mathds of tex.stackexchange.com/a/452113/128553 for comparison. – CampanIgnis Jan 24 at 20:51
  • 3
    I usually suggest \newcommand{\numberset}[1]{\mathbb{#1} and then \newcommand{\Z}{\numberset{Z}}; this indirection makes it possible to change the font used for number sets in a single place. – egreg Jan 25 at 10:32
  • The LaTeX part of this answer is excellent. The mathematical comments in the first paragraph seem erroneous and distracting: at least in my experience from academic maths and computer science, the OP’s terminology (“integers” including negative numbers, and “natural numbers” for positive-only) is completely standard; the alternative terminology this answer suggests is simply wrong. So that paragraph seems erroneous, or at best (if that alternative usage is standard in some other field) irrelevant. – Peter LeFanu Lumsdaine Jan 25 at 13:22
  • 2
    @PeterLeFanuLumsdaine - Thanks. I've implemented your suggestion to drop the opening paragraph about math terminology. – Mico Jan 25 at 14:07
  • 1
    @Davislor - Thanks. I honestly think that the OP's main concern was, "why does neither \mathbb{Z} nor \Z work?" Vincent's parallel answer already mentions the mathalfa package and how it may be used to access various blackboard-bold fonts. – Mico Jan 25 at 18:22
4

As said by others, \mathbb is defined in amsfonts. For example,

is obtained with the following code.

\documentclass{article}
\usepackage{amsmath,amsfonts}
\begin{document}
\(\mathbb{Z}\)
\end{document}

However, I think it's worth here to mention the existence of the mathalpha package (see the documentation here) which allows to use many fonts with \mathbb. For example,

\documentclass{article}
\usepackage[bb=ams]{mathalpha}
\begin{document}
\(\mathbb{Z}\)
\end{document}

gives the same output than on the image given earlier. But other fonts could be used, for example

is obtained by replacing bb=ams with bb=boondox in the preceding code, and

is obtained with bb=pazo.

4

The other answers all say how to use legacy 8-bit fonts, which still work. If you’re using modern fonts with LuaLaTeX or XeLaTeX, it’s enough to load unicode-math. It also defines \BbbZ and lets you type in ℤ in your source.

You can also write \newcommand\Z{\mathbb Z} if you want that alias.

  • Hi, is it \Bbb Z (as MathJaX) or \BbbZ as have you written? – Sebastiano Jan 24 at 23:06
  • 3
    In unicode-math, \BbbZ, \mathbb{Z}, \symbb{Z}, and ^^^^2124 all work. \mathbb{Z} is what’s backward-compatible. – Davislor Jan 24 at 23:12
  • 3
    If you want \Z to work in LaTeX, you’ll have to define it yourself. – Davislor Jan 24 at 23:12
  • Thank you very much for complete explanation that I not know. My upvote there is :-) – Sebastiano Jan 24 at 23:13
  • 2
    +1. I thought that my expression -- "unless you load a font that natively provides blackboard-bold uppercase letters" -- was broad enough to comprise cases such as unicode-math, which loads a math font and contains instructions on what to with with \mathbb. However, I may have been too subtle... – Mico Jan 25 at 10:57
-4

tl;dr

{\bf Z}

The traditional notation, and Don Knuth's preferred notation (mine too), for the classical sets of numbers; is to use a bold Roman letter, thus: Z (for Zahlen---German for ``numbers''), the set of integers, may be entered {\bf Z}

If you have a real need to use double-struck letters in imitation of writing on black-boards imitating (really!) bold-face type (e.g. Z has another well-known meaning in your work in a particular field), then see the above answers (but Mico's differentiation of the Naturals and Integers is perfectly backward).

P.s. I don't have an electronic reference of Don Knuth saying this handy, sadly, but one does exist I believe.

  • 2
    I didn't want to say that LaTeX is better or worse than plain TeX. My comment was aimed to point out the difference: one can use {\bf Z} in plain TeX, but shouldn't in LaTeX. It's important because most people here use LaTeX and may be ill-driven by reading this post. Note that the question specifically mentions LaTeX. – egreg Jan 25 at 10:48
  • 2
    Sorry: one must not use {\bf Z} in LaTeX. Definitely. Portability between plain TeX and LaTeX has been out of concern for two decades. – egreg Jan 25 at 11:02
  • 2
    OK, do as you wish, but then don't complain when you try this simple document: \documentclass{memoir}\begin{document}${\bf Z}$\end{document} – egreg Jan 25 at 11:05
  • 2
    I'm really sorry that you insist in keeping your position. Really: syntax such as {\bf Z} has been deprecated for 25 years and will not be resurrected. It was a conscious decision by the LaTeX team and has proved good for several reasons. The question is about LaTeX and suggesting {\bf Z} is wrong. – egreg Jan 25 at 11:34
  • 1
    You asked (rhetorically, I would assume), "According to whom? Lamport?". Leslie Lamport has not been a leader in the development of LaTeX for more than 25 years. For several years after the transition from LaTeX2.09 (the last version for which Lamport played an important role) to LaTeX2e was implemented in 1994, some backward compatibility with legacy LaTeX documents -- detectable by their use of \documentstyle instead of \documentclass -- was preserved in order to facilitate the adoption of the newer commands. In case you hadn't noticed, though: LaTeX has come a long way since 1994. – Mico Jan 25 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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