# Spacing and correct use of braces in equations

I have a generic question about best practices in writing equations.

I usually don't care about braces when they're not mandatory, e.g. {x}_{i} and x_i. However, I noticed that their use changes the spacing between characters. For example, the output of P\left(x\right) is different from the output of P{\left(x\right)}, as the former adds a space between P and (x) while the latter doesn't.

Generally speaking, is there any good practice for the use of braces, from a WYSIWYM point of view? How do they affect spacing? How should they be used to tie something to something else, e.g. the function P to its argument (x)? Can they be safely omitted in {x}_{i} or should they be always used for some technical/semantic/typographic/phylosophical reason?

Also, should braces be used in combination with parentheses? For example, which of these should be used to get (a+b)(c+d)?

\begin{align}
\left(a+b\right) \left(c+d\right) \\
\left({a+b}\right) \left({c+d}\right) \\
{\left(a+b\right)} {\left(c+d\right)}
\end{align}


I haven't been able to find anything, because all search results for braces refer to \lbrace \rbrace rather than { }.

Additional question: I wrote \frac{1}{n^2} n and I noticed that I get no spacing between the 1/n² and n, while in a well-formatted equations there should be. How could more space be added, and should braces be used somewhere? I'm not asking if any \addMoreSpaceHere command exists, but if the use of braces affects spacing and how, for example \frac{1}{n^2} n and {\frac{1}{n^2}} {n}

Thank you!

• Start with this bed-time reading: Why is $ ... $ preferable to $$ ... $$?
– Werner
Commented Apr 19, 2018 at 16:35
• Thank you @Werner, actually I'm using "equation" and "align" environments in my document (I used  here only) but that's an interesting topic Commented Apr 19, 2018 at 16:48
• Which one for (a+b)(c+d)? None of yours: Just (a+b)(c+d) Commented Apr 19, 2018 at 17:17
• Ok, but what if I have something like (a+\frac{b}{2})(c+d) and I have to use \left( ... \right) to extend pharenteses vertically? In this case which one should I use? Commented Apr 19, 2018 at 17:22

Generally speaking, is there any good practice for the use of [curly] braces, from a WYSIWYM point of view?

Yes: Don't use curly braces unless it's essential to do so.

How do they affect spacing?

The most basic consequence of encasing a math object (an "atom") in curly braces is to changes its status to mathord ("math ordinary"). TeX inserts no extra space between objects of type mathord. In contrast, TeX (usually) does insert whitespace around objects of type mathbin ("math binary operator"; e.g., +, -, and \times), mathrel ("math relational operator"; e.g., =, >, and <), mathop ("math operator"; e.g., \sin, \log, and \det). Consider the following three examples -- in all cases, encasing the operators in curly braces is wrong.

The math-type of an object can affect not only the amount of whitespace (horizontal offset) that's inserted before and/or after it; it can also affect the position of subscripts and superscripts (vertical offset). E.g., ) and ] are of type math-close by default. The positions of any sub- and superscripts that follow the parentheses and brackets will vary greatly depending on whether or not ) and ] are encase in curly braces. And, with integral symbols, the placement of the lower limit of integration will be (negatively!) affected by an overzealous use of curly braces.

Once in a while, though, it will be advisable to change the math type of some math atom to math-ord. For example, if you need to typeset a decimal number using a comma (,) rather than a period (., aka "full stop" in some parts of the English-speaking world...) as the decimal marker, you should definitely write $3{,}14159$ rather than $3,14159$, since you need to override the math-punct ("math punctuation") status of the comma.

As always, if you know what you're doing, you'll (probably...) be alright using a few more curly braces than is absolutely necessary. Conversely, if you have a nagging suspicion that you don't really know if using an extra pair of curly braces is a good idea or not, you should probably err on the side of not using the curly braces...

• Thank you! So I should use \left(a+b\right) \left(c+d\right), is that right? And what about P{\left(x\right)}? I like this solution from a typographic point of view, but is this technically and "semantically" right? Commented Apr 20, 2018 at 2:32
• @Taekwondavide - Not overusing/needlessly using \left and \right would be another recommendation. Hence, do right (a+b)(c+d) and P(x). That way, there's also no need to use curly brace (which would be to undo the adverse spacing effects of the needless use of \left and \right). See Is it ever bad to use \left and \right? and “(” or “\left(” parentheses for more information on "Don't overuse \left and \right" subject.
– Mico
Commented Apr 20, 2018 at 2:49
• @Taekwondavide - Another posting which will, I hope, convince you not to overuse \left and \right is Spacing around \left and \right.
– Mico
Commented Apr 20, 2018 at 2:58

As for the \left( \right) spacing issues, I read about the package mleftright in the posts linked by Mico, which introduce the variants \mleft( \mright that fix the spacing (it works for (x) [x] {x} |x| ||x|| and so on).

If you have already been using \left( \right) in your document, you can redefine these commands:

\usepackage{mleftright}
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}

& P\left( \frac{a}{b} \right) &


Another nice and clean solution is \DeclarePairedDelimiter from package mathtools:

\DeclarePairedDelimiter
\DeclarePairedDelimiter\parentheses{\lparen}{\rparen}

$\parentheses{a} + \parentheses*{\frac{a}{b}}$


Starred version vertically stretches parentheses like \left( \right) does.

Both solutions allow to write f(a/b) with the right spacing (i.e. no space between function and argument) and with the right height for parentheses.