Tx · LaTeX & TikZ

How to Automatically Size Parentheses Across Multiple LaTeX Lines

Published By the 9to5Science editorial team

At a glance

  1. 1. Group the expression

    Put the lines that belong inside the same parentheses in one multiline math block.

  2. 2. Use aligned

    Place an aligned environment inside display math or an equation environment.

  3. 3. Enclose the block

    Put one automatic opening and closing parenthesis around the entire aligned environment.

  4. 4. Break inside

    Use row breaks within aligned and alignment markers to position continuation terms.

When a sum or product is too long for one line, you can break the expression while keeping one pair of parentheses sized to the full block. The key is to put the line breaks inside a single multiline math object, then place \left( and \right) around that object.

Use the aligned environment from the amsmath package inside display math or an equation environment. Unlike separate rows in align, the rows in aligned form one object. A delimiter pair around that object can therefore grow to fit all of its rows.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
\left(
\begin{aligned}
  &\sum_{i=1}^{n} a_i + \prod_{j=1}^{m} b_j \\
  &\quad + \sum_{k=1}^{r} c_k - \prod_{\ell=1}^{s} d_\ell
\end{aligned}
\right)
\end{equation}

\end{document}

This is a complete example; it needs only the amsmath package. The & characters mark alignment points, and \\ starts a new row. Here, the second row is indented with \quad. The outer \left( and \right) enclose the entire aligned block, so the parentheses account for the height and depth of both rows.

Why align behaves differently

Each row in align is a separate equation row, and its alignment cells are typeset separately. A \left on one row cannot match a \right on a later row: TeX expects the pair to be complete within the same math list. Trying to split the pair this way commonly produces a “Missing \right” error.

For example, this structure is not a way to make one pair span two rows:

\begin{align}
  x &= \left( \sum_{i=1}^{n} a_i + b \\
  y &= + \prod_{j=1}^{m} c_j \right)
\end{align}

The row break ends the first equation row before the closing delimiter appears. If you want one set of parentheses around both lines, use an aligned block inside a single display or equation, as in the complete example above.

If the rows must remain separate

Sometimes each line needs its own equation number or alignment structure, so replacing align with aligned is not suitable. In that case, choose a fixed delimiter size such as \Bigl( and \Bigr) (or a larger \biggl/\biggr pair). Fixed-size delimiters do not automatically inspect other rows, but they let you choose a consistent size for the lines.

You can also use invisible delimiters to make the visible opening and closing marks appear on different rows. An invisible delimiter is written as \left. or \right.. For example, a left parenthesis on the first row can be paired with an invisible right delimiter there, while the next row has an invisible left delimiter and a visible right parenthesis. This satisfies TeX’s pairing rule, but the two visible marks are sized from their respective rows; they are not guaranteed to match. Use fixed-size delimiters when visual consistency across separate rows matters.

Common mistakes

  • Putting \left and \right on different align rows. Pair them within one row, or put the rows inside a single aligned block.
  • Expecting \left. to print a delimiter. The dot means “no visible delimiter”; it is only a placeholder needed to complete a pair.
  • Using automatic sizing when the expression is still split into separate math objects. Automatic sizing sees only the material between its matching \left and \right, not other equation rows nearby.
  • Making every symbol large automatically. \left and \right resize delimiters, not the sums or products themselves. Use \sum and \prod in the usual way; their limits follow the normal display-style rules in this setup.
  • Using oversized parentheses for a small expression. Automatic sizing can look too tall when the enclosed material contains fractions or nested delimiters. In that case, test a fixed size such as \bigl( and \bigr) for a more restrained appearance.

The general rule is simple: if one pair of parentheses must fit several lines, keep those lines together inside one math object. Use aligned for a multiline expression within one equation; use fixed-size delimiters when the lines must remain separate.

References

  1. User’s Guide for the amsmath Package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.