TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define a new command to format \mathbb{E} in the same way as \sum - same size in display/inline formulae, and same treatment of sub/superscripts. The following seems to work...


...except that in display formulae, when inside automatically sized brackets (e.g. \left( \bbe_x \right)) it reverts to treating it as if it were in an inline formula (so smaller size, subscripts to the right not beneath).

I'm not sure what's causing this issue; any advice would be greatly appreciated!

share|improve this question
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces or enclose words in backticks `, they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the “code” button (with “{}” on it). As I did in my edit. Furthermore I cleaned you definition to make it more readable … – Tobi Apr 24 '12 at 17:42
Possible duplicate: tex.stackexchange.com/questions/5042/define-strange-operators – Tobi Apr 24 '12 at 17:43
up vote 9 down vote accepted

The \ifinner test is not safe for this application. Indeed the conditional is true whenever TeX opens a new math list when it's already in math mode.

The following Plain TeX code shows this:


will print inner in the log file. The same happens inside a \left-\right pair.

What you need is \mathchoice, which depends only on the current math style, which doesn't change in math sublists.


Probably \larger from the relsize package is better for display style:

share|improve this answer
Works perfectly, thanks a lot! – Thomas Bloom Apr 24 '12 at 18:20

\ifinner is the wrong sort of test here, you need \mathchoice

enter image description here



$a \bbe_0^1 $

\[ \bbe_0^1 \qquad \frac{\bbe_0^1}{\bbe_0^1} \]

share|improve this answer

Your Answer


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.