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.

I have a problem writing an equation in eqnarray environment, where I split a single line into two lines. The first line starting with \left[ and the second line ending with \right], but I could not compile it using latex.

share|improve this question
    
Welcome to TeX.SE. It is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. –  Peter Grill Nov 27 '11 at 19:13
    
This should be as simple as ending the first line with \right., and adding a \left. on the second line. If there are differences in vertical spacing between the lines, you'll need to use \vphantom. If you provide a small MWE we can adjust it for you. –  Peter Grill Nov 27 '11 at 19:15
    
By the way, you shouldn't use eqnarray. See, e.g., tex.stackexchange.com/q/197/586 –  Torbjørn T. Nov 27 '11 at 19:24
    
For still another discussion of the weaknesses of the eqnarray environment (and hence why one shouldn't use it!), see Lars Madsen's essay "Avoid eqnarray!", published in the PracTeX Journal in 2006, available at tug.org/pracjourn/2006-4/madsen. –  Mico Nov 27 '11 at 22:56
add comment

4 Answers

You should use align instead ofeqnarray as per this question that compares \eqnarray vs \align, and Stefan Kottwitz blong entry: \eqnarray vs \align environment.

Here is an example of using the \right., and \left. pair to complete the matching pair using the align environment. Note that the size of the brackets is not the same in the first example. This is due to the fact that the \left. <math> \right] of the second line does not see the vertical spacing of the \left[ <math> \right. that the first line does. To fix that you need to add a \vphantom{} with the term which has the largest vertical spacing in the first line. This yields the second result:

enter image description here

\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
\begin{align*}
  y &= \left[\frac{1}{2}\right. \\
    &\qquad + \left.x^2+c\right]
\end{align*}
%
\begin{align*}
  y &= \left[\frac{1}{2}\right. \\
    &\qquad + \left.x^2+c\vphantom{\frac{1}{2}}\right]
\end{align*}
\end{document}
share|improve this answer
    
There's a little typo in the second line before the image: you wrote \vpahantom{}. –  Gonzalo Medina Nov 28 '11 at 0:45
    
the style recommended in most "how to typeset math" manuals is to indent the lines starting with + by a couple of quads. in the texbook, ch.19, dek uses \qquad in several such examples. –  barbara beeton Nov 28 '11 at 15:00
    
@GonzaloMedina: Thanks, have corrected that typo. –  Peter Grill Nov 28 '11 at 16:22
    
@barbarabeeton: Thanks for pointing that out. Have added a \qquad. –  Peter Grill Nov 28 '11 at 16:23
add comment

Another option would be to use the big-g delimiters instead of the \left, \right construct; using the big-g delimiters you don't have to worry for pairing the symbols in every line:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  y &= \biggl[ \frac{1}{2} \\
    &+ x^2 + c \biggr]
\end{align*}

\end{document}

enter image description here

share|improve this answer
add comment

you can use the breqn package.

instead of \begin{equation} or \begin{equation*}, use the environment dmath or dmath*. the delimiters will be sized properly, and the line broken in an appropriate location. there are also multi-line environments if your display needs them.

there are some limitations; for details, see the package documentation -- texdoc breqn if you have a tex live installation; otherwise, look on ctan.

share|improve this answer
    
@barbaraL Out of curiosity, from the AMS submissions, do you know how frequently is breqn used in the wild. –  Aditya Nov 27 '11 at 20:53
1  
@Aditya -- i've grepped for the package name in some of the files in current production, and didn't find it. my guess is that it's not that well "advertised", and if an author isn't already using it when a book or paper goes into production here, the copyeditors are so used to the "old" methods of breaking lines that they just don't try it. (it was still very much a beta when michael downes died, so it didn't get the exposure here that would have put it into the local toolbox.) –  barbara beeton Nov 28 '11 at 14:52
    
Thank you for the info. Hopefully the usage of breqn will slowly pick up. –  Aditya Nov 29 '11 at 13:09
add comment

Another option is to use nath class. It is not completely compatible with amsmath, but does provide its own multi-line math environments, which might be sufficient for simple math displays.

One of the features of nath is automatic delimiter scaling that works across multiple lines. For example

\documentclass{article}
\usepackage{nath}

\begin{document}
\begin{equation}
  y = \wall [ \sum_{i=1}^n a_i \\
            + x^2 + c ] \return
\end{equation}
\end{document}

gives

enter image description here

share|improve this answer
2  
I'd say that nath is fully incompatible with amsmath. –  egreg Nov 27 '11 at 20:26
    
@egreg: The display math (align etc) and matrix commands (bmatrix etc), and extensible arrow from amsmath are incompatible with nath. Text mode commands (\text, \dots, \cfrac, \binom) work. It would have been much nicer if both packages had split their display math macros and other macros into separate packages which could be intermixed. –  Aditya Nov 27 '11 at 20:50
    
it's not completely true that amsmath is monolithic. there are several ancillary packages (which admittedly are automatically loaded by amsmath): amsopn (operator names), amstext (the \text facility) and amsbsy (bold symbols). (there's also amscd, but other packages serve that function better.) any of these can be used without amsmath; whether or not they're compatible with nath, i don't know. an overhaul of amsmath is tentatively scheduled for next year; nath is one of the non-ams packages on our list to look at, but i can't promise compatibilty after the overhaul. –  barbara beeton Nov 29 '11 at 17:44
    
Thanks @barbara. My guess is that compatibility with nath is difficult because nath changes a lot of TeX internals, like breqn. In some sense, like breqn, nath should be the one ensuring compatibility with amsmath; not the other way round. If amsmath could include some of the nath features ("correct" scaling of \left ... \right around operators with limits; an "intelligent" \frac macro (perhaps with a different name), automatic \substack if the subscript or superscript has multiple lines) that will be great. –  Aditya Nov 29 '11 at 18:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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