0

I'd like to import only the \mathbb{1} character from the unicode-math package into a document using the standard Computer Modern font along with the amsmath and amssymb packages, but I have no idea how to do this. Any help would be tremendously welcome!

Note: I would prefer NOT to use the bbol, mathbbold, bbm, ... packages. The only package I've encountered so far that provides a nice rendering of the character I'm looking for is unicode-math.

Rindler98
  • 119
  • Welcome to TEX.SE! Please explain what engine you are using. If you are using pdftex, then bbold should be in fact the correct choice, so then please explain why you would not prefer using it. If it's about the redefinition of \mathbb from amssymb: that can be easily taken care of. – campa Oct 14 '20 at 12:24
  • You might also try \usepackage[default]{fontsetup} to switch to New Computer Modern. – Davislor Oct 14 '20 at 17:30
  • You would not normally mix unicode-math with amssymb. It doesn’t cause an error, but amssymb will have no effect. – Davislor Oct 14 '20 at 17:33

1 Answers1

4

Compiling

\documentclass{article}
\usepackage{unicode-math}
\begin{document}
$a\mathbb{1}$
\end{document}

with lualatex yields

enter image description here

(The a is there just for the sake of comparison.)

Similarly, running pdflatex on

\documentclass{article}
\usepackage{bbold}
\begin{document}
$a\mathbb{1}$
\end{document}

enter image description here

The two results look quite identical, so I don't really understand your claim that

I would prefer NOT to use the bbol, mathbbold, bbm, ... packages. The only package I've encountered so far that provides a nice rendering of the character I'm looking for is unicode-math.

In fact, the standard math font with lualatex and xelatex is Latin Modern Math, and its documentation states explicitly

the double struck script is excerpted from Alan Jeffrey's bbold font

My guess is that your problem with loading bbold is that it overwrites the definition of \mathbb from amssymb. This can be easily circumvented by adapting the code of bbold.sty (it's just six lines of code)

\documentclass{article}

\usepackage{amsmath,amssymb}

\DeclareMathAlphabet{\mathbbold}{U}{bbold}{m}{n} \newcommand*{\boldone}{\mathbbold{1}}

\begin{document} $\mathbb{R}$ % that's still from amssymb $\mathbbold{R}$ % that's from bbold $\boldone$ % that's from bbold

\end{document}

enter image description here

Note, however, that once you use the symbol in a formula this solution will allocate a (possibly precious) math family; not an issue if you are not using lots of other fonts, but sometimes packages do things without you noticing. If you need only the 1, you could alternatively define

\newcommand*{\boldone}{\text{\usefont{U}{bbold}{m}{n}1}}
campa
  • 31,130
  • Using your very last solution, I get the following error (I'm using pdflatex with TeXstudio on Windows, with MikTeX):

    Font U/bbold/m/n/10.95=bbold11 at 10.95pt not loadable: Metric (TFM) file not found. $\boldone \textfont 9 is undefined (character 1). $\boldone{1}$

    – Rindler98 Oct 14 '20 at 17:08
  • I suppose I should add some files from bbold.zip to some directory, but I really wouldn't know where to put them. :/ – Rindler98 Oct 14 '20 at 17:09
  • @JilalJahangir Uhm, it works for me under TeXLive both under linux und windows. The error seems to suggest that your MikTeX installation is possibly not complete but I have no experience with MikTeX. – campa Oct 14 '20 at 17:12
  • @JilalJahangir No, never try to put files manually somewhere. The MikTeX package manager should handle this kind of stuff. I'm searching for similar issues here on the site. – campa Oct 14 '20 at 17:12
  • I've managed to get it to work (1) in TeXstudio, in a new document, using only your minimal working example above and (2) on Overleaf, in the actual document I needed the symbol for. TeXstudio produces a garbled, low-quality version of the character, while Overleaf renders it nicely. – Rindler98 Oct 14 '20 at 17:18
  • @JilalJahangir Which version of MikTeX do you have? It might be possible that in old installations (or if you have installed something manually) the bitmap font is used. But I've tested this on three different machines now (admittedly, all with TeXLive) and I get always the same (good) result. – campa Oct 14 '20 at 17:24
  • I'm using MikTeX 2.9. I checked and there were some package updates available, so I'm installing those now. – Rindler98 Oct 14 '20 at 17:30
  • TeXstudio does manage to render your code inside my document now, but it still produces a pixelated version of the character. I've seen the exact same pixelated character in my QFT course notes, so I suppose it's not an uncommon problem. – Rindler98 Oct 14 '20 at 17:37
  • @JilalJ I don't use MiKTeX, but do you have the bbold-type1 package installed (in the MiKTeX package manager or whatever it's called)? – frougon Oct 14 '20 at 22:19
  • @frougon I didn't, but I do now and the character suddenly renders flawlessly! Thank you! – Rindler98 Oct 14 '20 at 22:38
  • Glad I could help after wasting @campa's time. :-) – frougon Oct 14 '20 at 22:43
  • 1
    @frougon Oh, I thought that for some reason the bitmap fonts were being used but I didn't think that the type1 fonts were distributed as a separate package. And don't you worry: time spent delving into TeX's mechanisms is never wasted :-D – campa Oct 15 '20 at 07:27