Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been happily using the cancel package that allows to cross out parts of mathematical formulas for some time now.

However, today I noticed a very strange behaviour in the size of brackets located outside the cancelation in formulas with powers that had several terms. Depending on the number and combination of plus and minus signs in the power, the outer \left( and \right) brackets where unexpectedly larger or smaller than usual.

This makes it complicated to use them with equivalent non-cancelled terms or, as in my case, terms with only a difference in a sign. The simpler example of what I'm trying would be:

    \documentclass{article}
    \usepackage{cancel} 
    \begin{document}

    \begin{equation}
    \left[ \psi_0 \, \cancel{e^{-i \left( k_0 z-\omega_0t\right)}} \right] 
    \left[ \psi_0 \, \cancel{e^{i \left( k_0 z-\omega_0t \right)} } \right] 
    \end{equation}

    \end{document}

But I would like the brackets in both terms to be the same size.

I'm not sure if this is a bug or I am missing something. But even in the case it's a bug it would be helpful to know if there is any trick that would allow me to sort it out.

An image with two examples, one where the cancel command shrinks the brackets below the normal size and another where it enlarges them:

Two examples of anomalous bracket sizes caused by the cancel package

I've tried to find the rule to post it here, using from one to seven terms with different combinations of plus and minus signs, but unfortunately it seems to me such an erratical behaviour that I haven't been able to understand the global pattern. I post here some additional examples in case it can help an expert user to spot where the problem might be.

    \documentclass{article}
    \usepackage{cancel} 
    \begin{document}

    How the brackets normally look:
    \begin{equation}
    P =  \left[ {e^{1}} \right]
    \quad
    P =  \left[ {e^{-1}} \right]
    \quad
    P =  \left[ {e^{-\left(1\right)}} \right]
    \quad
    P =  \left[ {e^{-\left(-1\right)}} \right]
    \quad
    P =  \left[ {e^{-\left(12\right)}} \right]
    \end{equation}

    If there are brackets in the exponential, it matters whether the signs are inside or outside and even the number of characters as well:
    \begin{equation}
    P =  \left[ \cancel{e^{1}} \right]
    \quad
    P =  \left[ \cancel{e^{-1}} \right]
    \quad
    P =  \left[ \cancel{e^{-\left(1\right)}} \right]
    \quad
    P =  \left[ \cancel{e^{-\left(-1\right)}} \right]
    \quad
    P =  \left[ \cancel{e^{-\left(12\right)}} \right]
    \end{equation}

    With one to five terms preceded by a plus sign in the exponential, the outer brackets look normal, six or more, they are larger than usual:

    \begin{equation}
    P =  \left[ \cancel{e^{+1+2+3+4+5}} \right]
    \quad
    P =  \left[ \cancel{e^{+1+2+3+4+5+6}} \right]
    \end{equation}

    When the terms are preceded by a minus sign, the strange behaviour starts at five terms instead:

    \begin{equation}
    P =  \left[ \cancel{e^{-1-2-3-4}} \right]
    \quad
    P =  \left[ \cancel{e^{-1-2-3-4-5}} \right]
    \end{equation}

    When the first number in the exponent is not preceded by any sign the behaviour is quite erratical. 
    \begin{equation}
    P =  \left[ \cancel{e^{1+2}} \right]
    \quad
    P =  \left[ \cancel{e^{1+2+3}} \right]
    \quad
    P =  \left[ \cancel{e^{1+2+3+4}} \right]
    \end{equation}

    \end{document}
share|improve this question
    
Welcome to TeX.SX! –  Harish Kumar Oct 27 '13 at 0:35
    
@Qrrbrbirlbel, that made it, thanks. But I cannot flag the answer because it's a comment. :) –  Margaret Dumont Oct 27 '13 at 1:19
add comment

2 Answers 2

up vote 2 down vote accepted

The trick that made it was to use the smash command to remove the nominal height from the troublesome canceled factor with a negative exponent:

    \left( \smash{\cancel{e^{-i(...)}}} \right)

And then to add a vertical phantom that provided the proper height of the term with a positive exponent but without showing up in the formula:

    \left( \vphantom{\cancel{e^{i(...)}}} \smash{\cancel{e^{-i(...)}}} \right)

(@Qrrbrbirlbel's comment has disappeared, so I post his answer in case someone runs into the same problem.)

share|improve this answer
    
I removed my comment because I thought that I misunderstood you. It seems, I didn’t. :) –  Qrrbrbirlbel Oct 27 '13 at 2:16
add comment

The package uses the same tools as used to obtain \line and \vector in the picture environment. Because only finite set of slopes is provided, some roundings are needed, and they produce side-effects noticed by you.

Let us remind, that in \line(x,y), x and y should be integers from the interval [-6,6], without common divisors. In the package cancel either horizontal o vertical dimension of an entry is corrected (the precise rules are determined by the file cancel.sty).

share|improve this answer
    
Scherwen, this is an interesting explanation but it doesn't seem to me like it can be the whole story because, in the last example above, it can be seen that there isn't a clear trend (two terms gives a larger bracket, three terms normal size, and four terms larger bracket again). I would assume that if the slope decreases with the length of the formula, there might be a dephasing or mismatch with the proper height but it wouldn't oscillate, right? Anyway, shouldn't the cancel line have been coded with zero size so that it wouldn't affect the layout of the formula? –  Margaret Dumont Oct 27 '13 at 1:17
    
@MargaretDumont I have extended my answer (a little). As far as I understand, you want to know the source of the strange behaviour, not the way of uniforming brackets. –  Przemysław Scherwentke Oct 27 '13 at 1:34
    
Thanks, @przemyslaw-scherwentke, now it's clearer. I wanted to be able to solve the practical problem too, but Qrrbrbirlbel's comment has done the trick. –  Margaret Dumont Oct 27 '13 at 1:45
add comment

Your Answer

 
discard

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.