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.

Possible Duplicate:
Left/Right across multiline equation

Could someone explain why I can't get the left and right commands to work correctly

code:

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

\begin{equation}
\begin{align}
\label{eq:foo}
s_{i}^{G}= & \min
\left
(
   \sqrt
   {\
      \min
      ( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      ) 
      + 
         y
   }
   ,\\
   & 
   \sqrt
   {\
      \min
      ( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      ) 
      + 
      \min 
      ( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      )
   } 
\right
)
\end{align}
\end{equation}

\end{document}                                                          
share|improve this question

marked as duplicate by Werner, lockstep, zeroth, N.N., barbara beeton Sep 25 '12 at 20:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
The \left, \right constructs can not cross alignment boundaries, nor be on different lines. You need to close it with a \right. and begin it again with a \left. on the next line, or after the alignment points. Also, no need to put align within equation. The \align environment is all that is needed. –  Peter Grill Sep 25 '12 at 0:01
    
@PeterGrill on the wiki page it shows that you can en.wikibooks.org/wiki/LaTeX/… –  puk Sep 25 '12 at 0:04
    
You should note that the first left\{ is closed with a \right. on the first line, and the opened with a \left. on the second line. –  Peter Grill Sep 25 '12 at 0:05
    
Oh that's what the left. is. Could you, in the form of an answer, explain what the left. {} means, then I will accept it –  puk Sep 25 '12 at 0:08

3 Answers 3

up vote 5 down vote accepted

Once we

  1. replace the align environment to aligned (since it is within the equation environment and you want a single equation number).
  2. add a closing \right. before the end of the first line, and
  3. add an opening \left( on the second line after the alignment point

we get:

enter image description here

The \left and \right constructs can not cross line, or alignment points. If there is a need to open a \left on one line and close it on a subsequent line, then the first line needs to have a \right. before the end of the line, and the next line needs to have a \left. before the closing \right construct. Hence the \left, \right are balanced on each line. Similar logic applies to each side of an alignment point.

Code:

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

\begin{equation}
\begin{aligned}
\label{eq:foo}
s_{i}^{G}= & \min
\left(
   \sqrt
   {\
      \min
      ( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      ) 
      + 
         y
   }
\right.
   ,\\
   & 
\left.
   \sqrt
   {\
      \min
      ( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      ) 
      + 
      \min 
      ( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      )
   } 
\right)
\end{aligned}
\end{equation}
\end{document}   
share|improve this answer
    
what happened to the \begin{equation}? –  puk Sep 25 '12 at 0:11
1  
You can't use align within equation. Perhaps you are thinking of aligned, which you can use within equation. –  Peter Grill Sep 25 '12 at 0:14
    
ya but this is an equation so I need it numbered –  puk Sep 25 '12 at 0:15
    
worked like a charm. thank you –  puk Sep 25 '12 at 0:21
1  
This method will produce different sized left and right delimiters if one part of the equation is taller than the other. –  Ian Thompson Sep 25 '12 at 11:02

I think this is an example of why the \left...\right construct is more problematic than useful in some situations. I propose to use the \bigX, \BigX, \biggX, \BiggX family of commands instead; they do not need to be paired and one doesn't have to make manual adjustments when a line change occurs and the lines don't have the same height.

Below, two variations of the expression using this family of commands (the size of the inner parentheses was also corrected); the second one using additionally \smash:

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

\begin{equation}
\begin{aligned}
\label{eq:foo}
s_{i}^{G}= & \min
\biggl(
   \sqrt
   {
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
         y
   }
   ,\\
   &\quad 
   \sqrt
   {
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
      \min 
      \bigl( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      \bigr)
   } 
\biggr)
\end{aligned}
\end{equation}

\begin{equation}
\begin{aligned}
\label{eq:foo}
s_{i}^{G}= & \min
\Bigl(
   \sqrt
   {\smash[b]{
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
         y
   }}
   ,\\
   &\quad 
   \sqrt
   {\smash[b]{
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
      \min 
      \bigl( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      \bigr)
   }}\, 
\Bigr)
\end{aligned}
\end{equation}

\end{document}

enter image description here

As Guido mentions in his comment, a solution for the problem of the displacement of the equation number is to replace the combination of equation and aligned with multline:

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

\begin{multline}
\label{eq:foo}
s_{i}^{G}=  \min
\biggl(
   \sqrt
   {
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
         y
   }
   ,\\
   \sqrt
   {
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
      \min 
      \bigl( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      \bigr)
   } 
\biggr)
\end{multline}

\begin{multline}
s_{i}^{G}= \min
\Bigl(
   \sqrt
   {\smash[b]{
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
         y
   }}
   ,\\
   \sqrt
   {\smash[b]{
      \min
      \bigl( 
         (
            x_{i}^{G}-x
         )
            ^2, 
         (
            w_{T} - x_{i}^{G}-x
         )
            ^2  
      \bigr) 
      + 
      \min 
      \bigl( 
         (
            y_{i}^{G}-y
         )
            ^2, 
         (
            h_{T} - y_{i}^{G}-y
         )
            ^2
      \bigr)
   }}\, 
\Bigr)
\end{multline}

\end{document}

enter image description here

share|improve this answer
    
For the problem of the displacement of the equation number a solution in to replace the combination of equation and aligned with multline –  Guido Sep 25 '12 at 4:36
    
@Guido Thank you. I've incorporated your suggestion to my answer. –  Gonzalo Medina Sep 25 '12 at 12:57

As already mentioned, \left( and \right. are pairs, not \left( and \right).
There is a package called breqn that provides the possibility to use \left and \right across linebreaks:

Code

\documentclass{article}
\usepackage{amsmath}
\usepackage{breqn}

\begin{document}
\begin{align}
s_{i}^{G}= & \min
\left(\sqrt{\min((x_{i}^{G}-x)^2,(w_{T} - x_{i}^{G}-x)^2)+y}\right., \notag\\
   & \left.\sqrt{\min((x_{i}^{G}-x)^2,(w_{T} - x_{i}^{G}-x)^2)+\min((y_{i}^{G}-y)^2, (h_{T} - y_{i}^{G}-y)^2)}\right)
\end{align}

\begin{dmath}
s_{i}^{G}= \min \left(\sqrt{\min((x_{i}^{G}-x)^2,(w_{T} - x_{i}^{G}-x)^2)+y},\\
          \mathrel{\phantom{=}} \sqrt{\min((x_{i}^{G}-x)^2,(w_{T} - x_{i}^{G}-x)^2)+\min((y_{i}^{G}-y)^2, (h_{T} - y_{i}^{G}-y)^2)}\right)
\end{dmath}
\end{document}

The macro \notag hides the equation tag in the first line since both lines correspond to one and only one equation (or you use the aligned environment).

Output

enter image description here

Drawbacks

Closing \left( with \right. works fine as long as both parts of the equation are of equal heights. For an equation like (this is only a example, neither the equation itself nor the horizontal space in front of the second part should be a point of discussion):

\begin{align}
    x & = \left( \frac{1}{2} \right. \notag \\
     & \quad  \left. {} + 1\right)
\end{align}

The output does not look good:
enter image description here

Again, you can use breqn or, and this needs the author's attention, \vphantom:

\begin{align}
    x & = \left( \frac{1}{2} \right. \notag \\
      & \quad  \left. {\vphantom{\frac{1}{2}}} + 1\right)
\end{align}

\begin{dmath}
    x = \left( \frac{1}{2} \\
        \mathrel{\phantom{=}} {} + 1\right)
\end{dmath}

Output:
pic 3

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.