{(x+y)}^2 or (x+y)^2?
There is an argument that logically the squaring operation applies to the whole subterm so the {}
are correct. However it makes the {}
into a mathord which can affect spacing to adjacent terms and if the subterm is large (but \left \right
are not used so the brackets are not stretched) then the superscript could float up and become visually detached. So on balance, I think it's better to use the )^2
form.
\documentclass{article}
\begin{document}
${(x+y)}^2 + \sin{(x+y)}^2+{(x+\frac{\frac{A}{B}}{C}+y)}^2$
$(x+y)^2 + \sin(x+y)^2+(x+\frac{\frac{A}{B}}{C}+y)^2$
\end{document}
There's one major reason against using {}
that isn't mentioned in the other answers: like \left(...\right)
, it makes the spacing inside lose its flexibility. Look at this example:
In the first case, the space around the -
is shrunk to make everything fit into the line, but the {}
around the parentheses has the effect that the space around the +
isn't shrunk. In the second case you get even spacing: the shrinking around the -
is the same as around the +
.
\documentclass{article}
\setlength{\textwidth}{4.9cm}
\begin{document}
$a+{(x+y)}^2$ versus $a+(x+y)^2$
\end{document}
Also if you want to prevent a line break, don't use {}
around the expression, use \nobreak
instead at appropriate places, like in (x+\nobreak y)^2
.
Months later...
A relevant passage of the TeXbook (Chapter 16, p129) is the following, which is in agreement with David's answer; I thought I should add it here, for completeness.
A superscript or subscript following a character applies to that character only; but when following a subformula it applies to that whole subformula, and it will be raised or lowered accordingly. For example,
$((x^2)^3)^4$
${({(x^2)}^3)}^4$
In the first formula the
^3
and^4
are superscripts on the right parentheses, i.e., on the)
characters that immediately precede them, but in the second formula they are superscripts on the subformulas that are enclosed in braces. The first alternative is preferable, because it is much easier to type and it is just as easy to read.
(my emphasis)