163

I am trying to get the digit one printed the \mathbb{} font in math mode, however the command

\mathbb{1}

outputs some rubbish. I certainly saw the character I am after in some pdf's generated from latex, hence my question: how do you get it to work?

  • 3
    possible duplicate of How do I make a blackboard 1? – Gonzalo Medina Aug 27 '11 at 15:04
  • The \mathbb provided as part of the amsfonts package does not provide numerals. Section 3.3 of amsfonts' documentation states that the \mathbb command it provides uses the msbm font and so supports only uppercase letters: no lowercase, no numerals. – mas Aug 27 '11 at 15:52
  • note that using any package that provides a complete blackboard bold font overrides the \mathbb provided by amsfonts. if you wish to replace only the digit "1", you can use the method described here: Importing a single symbol from a different font – barbara beeton Feb 13 '17 at 17:30
  • 1
    off topic: After years reading math texts, I think that the most common notation for the characteristic function of a set $A$ is \chi_A. – Sigur Feb 27 '18 at 11:25
  • How come "they" don't fix this? Is there a fundamental problem? – Alec Jacobson Jan 20 at 4:41
189

Since \mathbb doesn't support digits (with amssymb or txfonts) you may use bbm

\documentclass{article}
\usepackage{bbm}
\begin{document}
\[ \mathbbm{1} \]
\end{document}

bbm example

or dsfont, the doublestroke package:

\documentclass{article}
\usepackage{dsfont}
\begin{document}
\[ \mathds{1} \]
\end{document}

dsfont example

| improve this answer | |
  • 8
    I guess \mathbbm{1}is the best in terms of consistency with \mathbb. – Alfredo Hernández Nov 28 '14 at 23:15
  • You can also add \newcommand{\1}[1]{\mathds{1}\left[#1\right]} to your preamble to create a quick indicator function that handles what you wanna put inside it. – Guilherme Salomé Nov 8 '16 at 23:07
  • I get the error: File bbm.sty not found. Also File dsfont.sty not found. – Albert May 10 at 16:28
17

Another option is to use bbold package.

\documentclass{article}
\usepackage{bbold}
\begin{document}
\[ \mathbb{1} \]
\end{document}

bbold example

Though it ruins the letters.

| improve this answer | |
12

I'm surprised no one has mentioned this, but you can use the unicode-math package. Note that you need Xe(La)TeX or LuaLaTeX to use this package.

\documentclass{article}

\usepackage{amsmath}
\usepackage{unicode-math}

\begin{document}
    $\mathbb{1}$
\end{document}

enter image description here

| improve this answer | |
  • Perhaps because it can't be used with pdflatex: "Package unicode-math Error: Cannot be run with pdfLaTeX!" – user26800 May 24 at 16:53
  • Only this worked for me with LuaLaTex. – Evgeny Kuznetsov Jun 5 at 13:34
4

A new solution: use newtxmath package.

With code:

\usepackage{newtxmath}

$\vmathbb{ABCDEFGHIGKLMNOPQRSTUVWSYZ}$
$\vmathbb{abcdefghijklmnopqrstuvwxyz}$
$\vmathbb{0123456789}$

which results: enter image description here

Also, this solution is compatible with the ACM Template's whitelist restriction, since there're no need to import other packages, the document class asmart already imported the newtxmath. However, there's some bugs if you do not explicitly import the newtxmath, if you try to type blackboard bold 1 in this situation, try \vmathbb{s}, this outputs the right format.

Here's the document of the newtxmath: http://ctan.mirror.colo-serv.net/fonts/newtx/doc/newtxdoc.pdf

Update: In new version of TeX (2020), I found that \vmathbb{1} worked correctly.

| improve this answer | |
  • Why the lower case letters (except k) are not supported? – Hosein Rahnama Mar 15 at 19:56
1
\documentclass{article}        
\usepackage{anyfontsize}         
% For documents in 10pt, 11pt or 12pt     
% \def\one{\mbox{1\hspace{-3.85pt}\fontsize{11}{14.4}\selectfont\textrm{1}}} % 10pt    
\def\one{\mbox{1\hspace{-4.25pt}\fontsize{12}{14.4}\selectfont\textrm{1}}} % 11pt    
% \def\one{\mbox{1\hspace{-4.75pt}\fontsize{13}{14.4}\selectfont\textrm{1}}} % 12pt    
\begin{document}    
You can use either $\one$ or $\one\{A\}$ or $\one_{A}$.
\end{document}

enter image description here

| improve this answer | |
  • Welcome to TeX.SE. Do note that \rm is considered deprecated for a LaTeX document. It also doesn't take an argument; instead, it acts as a switch. Thus, instead of \rm{\fontsize{11}{14.4}\selectfont 1}, do write \fontsize{11}{14.4}\selectfont\textrm{1}. Also, is there something that can be done to produce less of an overlap/clash between the tops of the two 1 numeral? – Mico Feb 12 '17 at 16:27
  • The correct metrics depend on the font and font family, I guess. I typeset most of my documents with \usepackage{mathptmx}, a Times like font, and the code given works just perfectly. Adjust the argument of \hspace accordingly. – Jotazuma Feb 12 '17 at 17:19
0

This worked for me:

\usepackage{mathbbol}

+\mathbb{1}+

Actually, I'm using LyX, so I put \usepackage in the preamble and then simply used \mathbb with a 1 inside a formula box. It still displays as `rubbish' but renders fine as PDF.

If you don't like the discordance in LyX, you can say something like

\def\bbone{\mathbb{1}}

in the preamble, and then use \bbone in your document, or variants on this theme.

My 2c.

| improve this answer | |

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.