29

Using beamer. Let's say I want to write A+B but with the plus invisible in one slide and visible in the next one. I think I read somewhere that more space is left normally around the + for being a binary operator. It seems to be that A\phantom{+}B leaves only the space of the sign +. How can I get all the space I need.

0

2 Answers 2

30

Need to add additional {} which emulate a binary operator as TeX thinks there is something on either side of the +:

$A\phantom{{}+{}}B$
4
  • What is the difference between your answer and Stefan's? Is one better? Commented Sep 23, 2011 at 15:34
  • @Quinn: AFAIK both add identical spacing around the symbol for a binary operator, but the \mathbin better captures the intent of what you are doing. Commented Sep 23, 2011 at 15:47
  • When I use &\phanom{=}H... on one line of an align environment and then &=H... on the next, they are misaligned, and using (either of) your trick(s) works. According to your (and Stefan's) explanation, this is because the first = one is not a binary operator whereas the second = is. Am I correct in deducing that the reason the second = is considered a binary operator is because TeX considers the text at the end of the previous line to be to the left of =? Commented Sep 23, 2011 at 18:16
  • Not exactly sure I fully understand, perhaps it is best to post an additional question with a full MWE, but using F&\phantom{{}={}}H should produce the proper spacing. Commented Sep 23, 2011 at 18:26
29

Use \mathbin for making the invisible symbol a binary operator:

$A\mathbin{\phantom{+}}B$
4
  • What is the difference between your answer and Peter's? Is one better? Commented Sep 23, 2011 at 15:34
  • I would think @Stefan's answer is more clear, since you literally define \phantom{+} to act like a binary math operator (via \mathbin. In my opinion, one would only obtain @Peter's solution through experience with this problem, or perhaps a couple of compiles to see whether the spacing is correct.
    – Werner
    Commented Sep 25, 2011 at 14:33
  • 1
    @Werner: The spacing will be identical. The {} on either side of the + lets TeX know that there is an item of zero width on either side of the +. But, I do agree that in this case, that \mathbin more clearly captures the intent. Commented Sep 25, 2011 at 22:00
  • 5
    they may work the same in \phantom, but they dont at the beginning of a line. if i start a line with a logical and, it will attach to the next variable like a unary operator, \mathbin doesnt fix this, {} does.
    – peter
    Commented Nov 23, 2012 at 10:44

You must log in to answer this question.

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