136

I have a very long equation that must be separated into two lines, and it has several pairs of nesting \left \right delimiters. Unfortunately, it seems that they need to be on the same line in order for them to work.

Also I'm using the align environment because I need the aligning functionality. Is there a way to have the size of delimiters automatically adjusted over multiple lines?

8 Answers 8

44

The breqn package is a package that defines a set of new math environments, with the purpose of enabling automatic line breaking of displayed math. These new environments also let you have \left and \right on different lines, though it is not the main goal of the package.

Note that the package has several known problems and incompatibilities, so depending on your use case it might not be for you. I recommend a look at the manual.


The example below is one where you definitely shouldn't use \left and \right in the first place, but it serves to illustrate that it works. The dmath environment is similar to equation.

enter image description here

\documentclass{article}
\usepackage{geometry}
\geometry{a5paper, margin=5cm}

\usepackage{breqn}
\begin{document}
Automatic breaking:
\begin{dmath}
55 - \left(1+2+3+4+5+6+7+8+9+10\right) = 0
\end{dmath}

Manually breaking a line seems to work as well:
\begin{dmath}
55 - \left(1+2+3+4+\\5+6+7+8+9+10\right) = 0
\end{dmath}
\end{document}
10
  • 1
    Is it compatible with amsmath and amssym? Commented Oct 13, 2011 at 9:10
  • 2
    @TobiasKienzler Judging from the manual, yes, but load breqn after any other packages dealing with math, such as those you mentioned. Commented Oct 13, 2011 at 9:16
  • 1
    Warning that breqn package caused errors in my existing align equations; seemed to be related to the underset command. Using virtual dot delimiters (\right.) was a much simpler solution in this case - the answer by Mark Mikofski
    – JStrahl
    Commented Apr 30, 2018 at 13:08
  • 3
    Would be good to add an example to this.
    – kennyB
    Commented Nov 14, 2019 at 23:53
  • 2
    breqn is incompatible with unicode-math. They promised to add Unicode math in 2009. It's 2020. So I would say breqn is dead.
    – facetus
    Commented Oct 11, 2020 at 5:26
102

You can't.

You can use some thing like \biggl, \biggr, or \left.\vphantom{...}\right). For example:

\[
\begin{split}
a &= \left( \frac12 + \frac13 + \frac14 \right. \\
  &\quad \left. {}+ a + b + c \vphantom{\frac12}\right)
\end{split}
\]
12
  • 13
    Note that the alignment points (the &s) have to be outside the \left/\right.
    – Lev Bishop
    Commented Jun 22, 2011 at 3:30
  • 1
    Could one modify \left and \right to include \vphantoms of all the lines in between? Commented Oct 13, 2011 at 9:12
  • 3
    @TobiasKienzler: It's not easy to determine what to put in the \vphantom. TeX cannot understand the meaning of the equations. Anyway, you can use breqn.
    – Leo Liu
    Commented Oct 13, 2011 at 13:14
  • 4
    It's funny that even Word can automatically break equations over multiple lines and has no problems of breaking inside matching braces. After decades LaTeX still can't do it. I thought that the LaTeX's best part in contrast to Word is separation of content and presentation. “You can just concentrate on writing” is a usual motto of LaTeX aficionados when they try to explain the advantage of using LaTeX.
    – facetus
    Commented Oct 11, 2020 at 7:47
  • 1
    This is a better answer for more general situations.
    – Ziqi Fan
    Commented Jan 3, 2021 at 13:47
62

The solution for me was to use virtual dot delimiters

\frac{\partial F}{\partial x} &= \left[ \frac{\partial y}{\partial z} \right. \\
                              &* \left. \frac{\partial z}{\partial x} \right]

which was the comment posted by percusse in this question which was marked as a duplicate.

The virtual dot delimiters are in Leo Liu's answer above, but a TeX n00b like me wouldn't have seen it.

FYI Sphinx-1.1.3 already supports multi-line math with the math directive using the AmSMath LaTeX package, i.e. breqn is not necessary.

3
  • 4
    This doesn't give the right sizes if the material on the first and second lines have different height. Leo Liu's answer corrects for this by adding the \vphantom. Commented Nov 13, 2012 at 23:09
  • Thanks eldering, that's very good to know! Commented Nov 14, 2012 at 6:57
  • 1
    I could not see where sphinx makes a line break with \left in the link which you provided. How does sphinx solve the problem? Commented Apr 15, 2017 at 19:54
6

Have a look at the nath package.

3
  • 1
    Is it compatible with amsmath? Commented Oct 13, 2011 at 9:08
  • 2
    @Tobias: No. As I know, it is uncommon to use nath.
    – Leo Liu
    Commented Oct 13, 2011 at 13:12
  • 2
    @Tobias: nath is incompatible with amsmath; it does provide some support for multi-line display, and lot of nice features like automatic scaling of delimiters (no need for \left ... \right) that also works across line breaks, ignoring the height of the subscripts and superscripts (of operators like \sum) when calculating the scaling of delimiters, smart display of \frac, amongst others which do are cumbersome when using amsmath.
    – Aditya
    Commented Oct 13, 2011 at 16:34
2

I had the same problem. I wanted to show this equation

\begin{equation*}
    V_{sal} = -\left(1.V_8 + \frac{1}{2}.V_7 + \frac{1}{8}.V_6 +\frac{1}{8}.V_5  + \frac{1}{16}.V_4 \right.\\
     \left. + \frac{1}{32}.V_3 + \frac{1}{64}.V_2 + \frac{1}{128}.V_1\right) 
\end{equation*}

but since it is too long (in a two column document), I used multline enviroment but it gives an error (something like Missing \right. inserted. \end{multline*} or Extra \right. \end{multline*}). I solved it with this new code

\begin{multline*}
V_{sal} = -\left(1.V_8 + \frac{1}{2}.V_7 + \frac{1}{8}.V_6 +\frac{1}{8}.V_5  + \frac{1}{16}.V_4 \right.\\
 \left. + \frac{1}{32}.V_3 + \frac{1}{64}.V_2 + \frac{1}{128}.V_1\right) 
\end{multline*}

Note that I added a \right. at the end of the first row and \left. at the beginning of the second row.

1
  • 1
    Welcome to TeX.SE! Your answer is the same as of @Mark Mikofski (difference are only in used parenthesis/ bracked.
    – Zarko
    Commented Jan 10, 2021 at 15:39
2

The previous "automated" solutions all use certain packages that have compatibility issues with amsmath. Here is a sort-of-automated solution that does not require additional packages.

This solution uses \vphantom and is in essence the same as the previous answers using this command.

% split \left and \right across two lines
% use only between \[ and \] (modify as needed for \begin{equation}\end{equation}, etc.)
\newcommand\MatchBrackets[2]{\left[#1\vphantom{#2}\right.\]\[\left.\vphantom{#1}#2\right]}
\newcommand\MatchParentheses[2]{\left(#1\vphantom{#2}\right.\]\[\left.\vphantom{#1}#2\right)}

Usage:

\[\nabla h=\MatchParentheses{\int_0^{e^5}e^{-z^2}dz+\frac12\cdot\cos\left(\frac12\cdot x\right)\cdot\cos(y),}{-\frac12\cdot\cos\left(\cos\left(\frac12\cdot y\right)\right)\cdot\sin\left(\frac12\cdot y\right)-\sin(x)\cdot\sin(y)}\]

(Idea taken from Wintz's comment here. Example modified from zdim's answer here.)

1
  • I welcome suggestions/feedback on the "user interface" for these commands—is "\MatchParentheses" a good name? should I make the command take 4 arguments, with two of the arguments specifying the delimiter symbols? "(), [], {}, ..." etc. Commented May 20, 2023 at 0:05
0

I came here from this recent question on the same topic, and even if this is an old question, and even if it is likely a LaTeX question, I think it might be useful for some people to have a ConTeXt answer here.

Since a few years, displayed formulas in ConTeXt are typeset as paragraphs, which has made it possible to break inside \left \right constructions. Below I show an example with the formula from the question I arrived from.

We use align=slanted to have the first line flushed left and the last one flushed right (if there were more lines, they would be centered). We also use a margin. The \breakhere tells where to break the formula.

\starttext

\samplefile{knuthmath}

\startformula[align=slanted,margin=3em]
  P^^{ij}
  = -2 \sqrt{-g}
    \left\{
      G^^{ijlm} \dot K__{lm} + \alpha K^^{ij} K - \alpha g^^{ij} K__{lm} K^^{lm} +
      \alpha R^^{ij}^^^^{3} \breakhere
      - g^^{ij}
      \left[
        \left(
          \frac{\alpha}{3} + 2\beta
        \right)
        (R^^^^{3} - 3 K__{lm} K^^{lm} + K^^2) + \gamma
      \right]
    \right\}
  \numberhere[Pijsol]
\stopformula

We see in \in{Equation}[Pijsol] that \unknown

\stoptext

A formula that breaks inside left and right constructions

(The curious person can notice that ^^ and ^^^^ are used. They are used to denote indices (rather than powers or what-else). This can be useful in case of accessibility, and is not really important here.)

0

I recently wrote a longmath package that deals with the problem at the Lua level, so it works with lualatex.

It allows you to have delimiter groups over multiple lines, or link delimiters in different (sub)formulas to each other, automatically adapting their sizes to the content between them.

\documentclass{article}
\usepackage{longmath}
\usepackage{amsmath}
\begin{document}
\begin{align}
            x &= \lleft {label1} ( 1 + 2 + 3 \\
              &  \qquad + 4 + 5 + 6 + \frac{1}{2} \rright {label1} )
\end{align}
\end{document}

Here, label1 is a label that links the ( and ) to each other. They will have the same size, adapted to the fraction.

You must log in to answer this question.

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