30

I have a question about my expected value symbol in my latex document. When I use \mathbb{E}, it actually gives me this:

enter image description here

rather than this:

enter image description here

Can someone explain this to me please, because I prefer the second symbol, it's more common in the literature than the first one.

5
  • 6
    This depends on the mathfonts you actually loaded. What's your preamble?
    – Bernard
    Commented May 3, 2017 at 12:48
  • 3
    Remove \usepackage{bbold} and do \usepackage{amssymb} instead.
    – egreg
    Commented May 3, 2017 at 12:54
  • 1
    Actually I have both \usepackage{bbold} and \usepackage{amssymb}. When I removed \usepackage{bbold}, the expected value symbol looked exactly like I wanted, but unfortunately I have {\mathbb{1}} than don't look good anymore Commented May 3, 2017 at 15:52
  • I tried to put \usepackage{bbold} before \usepackage{amssymb} so that {\mathbb{1}} works fine and the expected value symbol looks as I wanted too, but it doesn't seem to work. Does someone have an idea? Commented May 4, 2017 at 13:01
  • You also have dsfont that gives you \mathds{1} and has a much finer output that goes well with Computer Modern.
    – Manuel
    Commented May 5, 2017 at 11:52

3 Answers 3

32

You don't need to load bbold just for one of its symbols.

\documentclass{article}
\usepackage{amsmath,amssymb}

\DeclareRobustCommand{\bbone}{\text{\usefont{U}{bbold}{m}{n}1}}

\DeclareMathOperator{\EX}{\mathbb{E}}% expected value

\begin{document}

$\EX(f)+\bbone$

\end{document}

enter image description here

2
  • 1
    Why is it bad to load bbold just for one symbol?
    – ck1987pd
    Commented Apr 18, 2021 at 9:36
  • 2
    @C.Koca Because it wastes a precious math group (there are only 16 of them). Since such symbol is not subject to changes due to \mathbf or similar commands, it's simpler if we typeset it in text mode.
    – egreg
    Commented Apr 18, 2021 at 9:54
3

I found a solution. Instead of usepackage{bbold} which was necessary for {\mathbb{1}} otherwise they looked like this

enter image description here

I used the package bbm and \mathbbm{1}. With this both the expected value and 1 symbols look fine.

0

I found a solution for the same problem but with a slightly different context. I'm using LuaLaTeX with MiKTeK on TeXstudio. I wanted to use the STIX2 fonts (\setmainfont{STIX Two Text} \setmathfont{STIX Two Math}) while having the expectd value symbol that the original question also wanted; but the package unicode-math, which together with fontspec enables the integration of STIX2 with amssymb, amsmath and amsfonts (the three should be compiled before unicode math) made it so the expected value symbol that would come in default with amsfonts would be replaced with the expected value from the STIX2 package. The two solutions I found were (having them in the preamble):

Option 1: If you need to change just this one symbol:

\DeclareMathSymbol{\mathbbE}{\mathord}{AMSb}{"45}
\newcommand{\ex}{\mathbbE}

Option 2: If you anticipate needing to replace more symbols:

\DeclareMathAlphabet{\mathams}{U}{msb}{m}{n}
\newcommand{\ex}{\mathams{E}}

With either way you can have whatever font you want but ensure to have the desired expected value sign.

For instance (need to be compiled with LuaLaTeX or XeLaTeX, not PDFLaTeX):

\documentclass{article}
\usepackage{amsfonts, amsmath, amssymb}
\usepackage{unicode-math, fontspec}
\setmainfont{STIX Two Text}
\setmathfont{STIX Two Math}
\DeclareMathAlphabet{\mathams}{U}{msb}{m}{n}
\newcommand{\ex}{\mathams{E}}
\newcommand{\var}{\mathams{V}}
\begin{document}
\noindent STIX2 looking symbols:
\[\mathbb{E}, \mathbb{V}\]
AMS looking symbols:
\[\ex, \var\]
\end{document}

enter image description here

1
  • Welcome to TeX.SE! Can you please show compilable TeX code for a fast proof of your solution(s)? And can you add an screenshot of the results?
    – Mensch
    Commented Mar 12 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .