eqnarray vs. align

There’s a lot of freely available documentation for LaTeX, but there’s a pitfall: some documents that are still online are outdated and therefore contain obsolete information. Documents like “Obsolete packages and commands” (“l2tabu”) address the need of up-to-date information.

For instance the obsolete eqnarray environment frequently appears in questions of new LaTeX users and many people including me usually answer: don’t use eqnarray and give advice how to use the align environment of amsmath instead.

Here’s a summary of the problems with eqnarray:

  • the spacing around relation symbols are inconsistent,
  • long equations might collide with the equation numbers,
  • there could be problems with labels and references.

Here is one small example document just to illustrate the space inconsistany problem:

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{minipage}{0.5\textwidth}
equation:
\begin{equation*}
  z_0 = d = 0
\end{equation*}
\begin{equation*}
  z_{n+1} = z_n^2+c
\end{equation*}
align:
\begin{align*}
  z_0 &= d = 0 \\
  z_{n+1} &= z_n^2+c
\end{align*}
eqnarray:
\begin{eqnarray*}
  z_0 &=& d = 0 \\
  z_{n+1} &=& z_n^2+c
\end{eqnarray*}
\end{minipage}
\end{document}

Compile for yourself and examine it, if you want. For a quick look here’s a screenshot of the output:

eqnarray vs. align

Notice the difference of the spacing around the equal sign in the eqnarray environment compared to equation and even compared to the other equal sign inside the first eqnarray line.
If you try to repair the spacing by adjusting \arraycolsep you will notice that all other arrays including matrices will be affected too. So the best solution is to use amsmath, this package provides even more environments useful for multiline formulas and a lot more enhancement for mathematical typesetting.

See the amsmath user’s guide.

For further information regarding this topic you may have a look at the article “Avoid eqnarray!” by Lars Madsen published in the PracTeX Journal 4 2006.

This topic was discussed on MatheBoard.

12. April 2008 by stefan
Categories: Mathematics | 92 comments

Comments (92)

  1. Very useful! I have been wondering what the difference is. Thanks!

  2. Where is the documentation and specifications for the align environment ? For example, how do you control if it aligns a certain column left or right ?

  3. Hi Brad,

    the align environment has an implicit {rlrl…} alignment of its columns. The environment is documented in the amsmath user’s guide, further information can be found in the general Mathmode document.

    Stefan

  4. One problem with the align environment is it appears that the pause command in Beamer does not work in align as it does in eqnarray. This may seem minor, but it’s important in my lectures to be able to step through multiline equations. Align does seem to be much nicer otherwise, so I would appreciate if anyone has advice on the pauses. Thanks!

  5. Bob,

    Beamer’s pause doesn’t actually work inside any amsmath environment, “since these do really wicked things” according to the Beamer manual (v.3.06, page 63). You can find some workarounds through Google, though just using eqnarray in this case is the simplest.

  6. You could step through align environments using the uncover macro. It works for unnumbered (starred) and numbered align environments, in the last case an empty untagged last line is necessary, see the beamer user guide 23.4 Uncovering Tagged Formulas Piecewise.

  7. Thanks for the responses. The uncover solution works well. I wish I would have checked back here sooner. I’ll be using that a lot from now on. Thanks.

  8. Hi, i’ve got a Problem with align.
    According to your article I started to change the eqnarray s in my documents into align s. But in a certain case, don’t know why, I get a strange space, here is an example:

    documentclass{scrreprt}

    usepackage{amsmath}

    begin{document}

    begin{eqnarray}
    a & = & b\
    b & = & c
    end{eqnarray}

    begin{align}
    a & = & b\
    b & = & c
    end{align}

    end{document}

    I’d be happy if you could explain to me, where these huge space in the align between = and b comes from and how I can avoid it. Thanks.

  9. Hi Christian!

    In align environments the & symbol doesn’t separate columns, it marks the relation symbol. The correct way would be:

    \begin{align}
    a & = & b \\
    b & = & c
    \end{align}

    The second & would cause an additional align-column, that’s why there’s that space. To see it try:

    \begin{align}
    a &= b & b &= a \\
    b &= c & c &= b
    \end{align}

    Stefan

  10. I’ve got a different problem with align. I would like to label an equation with tag{H_T}, but the subscript gets it really confused and unhappy. tag{{H_T}} doesn’t fix it. Any ideas?

  11. Hi Allen,

    use math mode in the argument of tag, tag{(H_T)} or tag{$H_T$}.

    Stefan

  12. Excellent, thank you!

  13. Thanks for your answer, now I understand how align works, think I’m gonna use it every time now. ;-)

    Christian

  14. Hi all,

    I have a couple more questions on align:

    Is it possible to adjust the multi-column behavior in align? I’m looking for something like array, but that could display math in equation-style (big vees etc.)

    Also, can I add/eat the space between the lines? I want to have dots leading to the last equation, but the line containing vdots is unevenly spaced with the ones around it:

    begin{align*}
    A_1 &= B_1\
    & vdots\
    A_n &= B_n
    end{align*}

    Thanks a lot,
    Andrew

  15. Hi Andrew,

    concerning multiple columns, amsmath provides several align-like environments, have a look at amsldoc.pdf. I’m often using the alignat environment when several columns are needed.
    Line specific spacing is possible, just state the space in square brackets after the linebreak, for instance:

    \begin{align*}
    A_1 &= B_1\\
    &\ \ \vdots\\[5pt]
    A_n &= B_n
    \end{align*}

    Negative space is possible as well:

    A_1 &= B_1\\[-5pt]

    Stefan

  16. Thank you Stefan!

  17. I have a problem with align. I’d like to label each row with label{} so that I can refer to the equations individually. I get an error message that multiple labels are not possible.
    begin{align}
    a &=blabel{eq1}\
    c &=dlabel{eq2}
    end{align}

  18. Hi Anna,

    there’s no problem in this code. This complete example is compilable without error and refers to both equations:

    \documentclass[a4paper,10pt]{article}
    \usepackage{amsmath}
    \begin{document}
    \begin{align}
    a &=b\label{eq1}\\
    c &=d\label{eq2}
    \end{align}
    See \eqref{eq1} and \eqref{eq2}. 
    \end{document}

    Try this one. Perhaps post a complete example here, like I did, that shows the error. Something else causes this problem, not visible in the piece of code here.

    Stefan

  19. Hi all,
    I just have few questions on fancy headings should some one extends a helping hand. I am writing a thesis and want to use this fancy thing. Here is what i have so far:

    documentclass[reqno,12pt, twoside ]{article}
    usepackage{fancyheadings}
    renewcommand{sectionmark}[1]{markright{thesection #1}{}}
    renewcommand{subsectionmark}[1]{markright{thesubsection #1}{}}
    rhead{leftmark\rightmark}
    fancyhead[LE,RO]{slshape rightmark}
    fancyhead[LO,RE]{slshape leftmark}
    fancyfoot[LE,RO]{thepage}

    My questions:1. I want to remove the heading for the main titles(sections) while keeping the page number as it used to be(left or right depending on…)
    2. I want to have the section title on the left hand side of the (even numbered pages) and the subsection title on the right hand side of (odd pages).
    Any help would be appreciated.

  20. Hi Alem,

    I recommend to use fancyhdr instead of fancyheadings, this is an early version. Since you are writing a thesis consider to use another class than article. The article class is appropriate for smaller documents. You could use report or book instead, there are even some dedicated thesis classes.
    book and report provide chapters. chapter starting pages would have another style, numbered but without heading. That may be what you would like to achieve.
    Have a look at the fancyhdr documentation for explanation and examples. If you still have questions just write them here.

    Stefan

  21. Thank you Stefan. I have been advised not use this chapter thing. If i do, i have to make sure that the word chapter should not appear where the chapter is supposed to begin. I can suppress it using chapter*{title}. The problem is then i need to have the chapter number before the title.

    Yes you right, with this book or report document classes, the header from the chapter or mains section will disappear which is what i want. The problem with this is again, it puts the page number for that page at the center. I want the page number to be on the right.

  22. Hi Alem,

    using a KOMA-Script class could help. They are much more customizable. Further they don’t write out “Chapter” and they provide a very good package for headings and footers. The position of the page number looks also like you wished.
    Test this small example:

    \documentclass[a4paper,10pt]{scrbook}
    \usepackage[automark]{scrpage2}
    \pagestyle{scrheadings}
    \usepackage[english]{babel}
    \usepackage{blindtext}
    \begin{document}
    \Blinddocument
    \end{document}

    The documentation will explain more, there’s a whole chapter dedicated to headings.

    Stefan

  23. Thanks Stefan. This was what i had been looking for.It solved my problem!!!

  24. I’ve been using align for years, however, the environment doesn’t seem to be a part of {iopart, iopams} (for publication in AMS journals), while eqnarray works – so there actually are situations where you can’t avoid using it. …and yes, the spacing is ugly!

  25. how to move the equation to left-hand side or right-hand side?

  26. To place the equations on the left side for the whole document, use the option fleqn for the document class or for the amsmath package.
    Alternatively, to align equation arrays to the left or to the right side, you could use the flalign environment. Just use an additional column separator & on the right respectively the left side.

  27. Thanks, you saved my day :)

  28. Hello Mr. Stefan!

    I would like to thank for the excelent post! I was using eqnarray a lot… However, it seems that there is a comment with a problem wich i have for my own, and is not answered… It seems that the problem is with the package “ntheorem”

    The problem is with align’s labels.

  29. Hello Mr. Stefan!

    I would like to thank for the excelent post! I was using eqnarray a lot… However, it seems that there is a comment with a problem wich i have for my own, and is not answered… It seems that the problem is with the package “ntheorem”

    The problem is with align’s labels.

    documentclass[a4paper,11pt,twoside]{article}
    usepackage[utf8]{inputenc}
    usepackage[portuguese]{babel}
    usepackage[pdftex]{graphicx}
    usepackage{amsfonts}
    usepackage{amssymb}
    usepackage{amsmath}
    usepackage[thmmarks]{ntheorem}
    begin{document}

    begin{equation}label{e1}
    equation1
    end{equation}

    begin{align}
    equation2 label{e2}\
    equation3 label{e3}
    end{align}

    begin{align}
    equation4 label{e4}\
    equation5 label{e5}
    end{align}

    begin{equation}label{e6}
    equation6
    end{equation}

    Equations ref{e1}, ref{e2}, ref{e3}, ref{e4}, ref{e5}, ref{e6}
    Equations eqref{e1}, eqref{e2}, eqref{e3}, eqref{e4}, eqref{e5}, eqref{e6}.

    Then there are errors with labels
    ! Package amsmath Error: Multiple label’s: label ‘e1′ will be lost.

    However, if i put

    begin{equation}label{e1}
    equation1
    end{equation}

    begin{align}
    equation2 \
    equation3
    end{align}

    Then ref{e1} gets reference to equation 2!
    It seems that if I remove ntheorem from the file, it compiles ok. Does anyone have the same problems? Is there a way to solve it? any link to proper documentation would help!

    Thank you very much.

  30. Hi Yul,

    the problem is indeed caused by ntheorem. But that package provides an option that takes care of it, just add amsmath as option:

    \usepackage[amsmath,thmmarks]{ntheorem}
  31. Hi all,
    I want latex to generate footnote consecutive numbers automatically through out my document. I tried to use this command footenote{text}.But it only generate consecutive numbers only with in a page. In a new page it always begins with 1 every time. I want all the footnotes through out the document to have different numbering say 1, 2…. I can do that manually using footenote[#]{text}. But it seems cumbersome. Can any one help me how to do it?

  32. Hi Alem,

    which document class do you use? Do you load the footmisc package or any other footnotes-related package?

  33. Hi Stefan,
    I use the document class scrbook. I loaded the footmisc package. But, it has not helped me.

  34. Hi Alem,

    that’s not the default behavior of scrbook and footmisc. In this example the second footnote will fall onto the second page and will get number 2:

    \documentclass{scrbook}
    \usepackage{footmisc}
    \begin{document}
    text\footnote{Test1}
    \newpage
    text\footnote{Test1}
    \end{document}

    So, there’s information missing. Perhaps post your preamble, I guess it’s caused by an option or package you didn’t mention. For instance, footmisc provides the option perpage, this causes such numbering per page. Or send me the preamble or a document by email to check.

    Stefan

  35. Hi Stefan,
    Here is my preamble
    documentclass[12pt,a4paper,twoside,openright,BCOR=1cm]{scrbook}
    usepackage{footmisc}
    usepackage[english]{babel}
    usepackage{blindtext}
    usepackage{lmodern}
    usepackage{fixltx2e}
    usepackage{titlesec}
    usepackage{amscd}
    usepackage{amssymb}
    %usepackage[margin=4cm]{geometry}
    %usepackage[a4paper]{geometry}
    usepackage{amstext}
    usepackage{mathrsfs}
    usepackage{relsize}
    usepackage{mathptmx}
    usepackage{makeidx}
    usepackage{fancyhdr}
    usepackage{textcomp}
    usepackage[T1]{fontenc}
    usepackage{verbatim, amsmath, amsfonts, amssymb, amsthm}
    usepackage{microtype}
    usepackage{setspace}
    usepackage{pfnote}
    usepackage{fnpos}
    usepackage[final]{hyperref}
    hypersetup{colorlinks=true, linkcolor=blue, anchorcolor=blue,
    citecolor=red, filecolor=blue, menucolor=blue, pagecolor=blue,
    urlcolor=blue}
    Alem

  36. Hi Alem,

    just remove that line:

    usepackage{pfnote}

    The package pfnote resets the footnote counter for each page. As I believe that this is its only purpose, you would not need it.

    Stefan

  37. Thank you very much Stefan. I removed that, and got what i exactly want. you have been really of a great help!
    Alem

  38. Hi all
    I just want to generate Nomeclature to my documents.I put the following and it perfectly runs. But it could not generate the nomenclatures. Any help please

    documentclass{article}
    usepackage{nomencl}
    %usepackage{makeidx}
    makenomenclature
    begin{document}
    section*{Nomenlature}
    nomenclature[ac]{$a$}{The number of angels per unit area}
    nomenclature {$N$}{The number of angels per needle point}%
    nomenclature {$A$}{The area of the needle point}%
    printnomenclature

    end{document}

  39. Hi Abebek,

    you have to run the program makeindex at the command prompt:


    makeindex filename.nlo -s nomencl.ist -o filename.nls

  40. Hi Stefan
    I am kind of new for latex. I read the manual and found also that i have to run the makeindex file as you said it. How do i run that? i could not find the file with that extension either.
    Abebek

  41. Run it at the command prompt. On Windows, that means: click Start, Programs, Accessories, Command Prompt or press the keys STRG and R together (Start, Run) and type cmd in that Start/Run dialog.

    A command prompt window opens, which is usually black and contains only text. Change to your docment directory using the cd command, then type this makeindex command above.

    This is not LaTeX, it requires some Windows/DOS knowhow. Some LaTeX editors such as TeXnicCenter can run makeindex automatically. Try the command prompt, otherwise I recommend to use TexnicCenter: http://www.texniccenter.org/

  42. Hi Stefan,

    I am writing a paper using “align” commands. In the beginning everything was OK, but later I got some strange vertical large spacing before a block of equations and after, when I used “align”, and this happening with only the blocks of equations WITHIN THE SAME PAGE. This problem occur for some “align” commands NOT all of them.

    Any idea what the source of this problem is ?
    Thanks in advance.

  43. Hi Ramirez,

    perhaps it’s just because LaTeX tries to fill up the page. You could try raggedbottom in your preamble. Otherwise you could send me a code example showing the problem by email.

  44. Hi Stefan,

    It Works ! raggedbottom solve the problem. Thanks a lot for the help !! Have a nice weekend.

  45. Hi all,
    I want to include a pdf picture in my latex document. I use document class scrbook and winedit editor and run it with pdflatex. I have inserted the graphic package where it should be and the following is what i tried
    begin{figure}[htb]
    begin{center}
    includegraphics[height=1in,width=1in]{myfig.pdf}
    caption{This is a figure.}
    end{center}
    end{figure}

    With this, it could not run let alone producing the pic. Any help please?

  46. to add few points:
    I also use pdflatex compiler. I put includegraphics[height=1in,width=1in]{myfig}
    without any extension as my figs are all in pdf and png formats.

  47. Hello,

    I am facing a problem with the align command.
    I need to include a running text in the first line followed by an equation in the second line. My latex code is as below:
    begin{align}label{mylabel}
    text{running text}nonumber\
    dot{vx} & = & (A_{i}+Delta A_{i})vx+(B_{i}+Delta B_{i})boldsymbol{u}
    end{align}

    On compilation of the above code, the equation gets aligned to the right and the text gets left aligned. However, I need the equation to be center aligned and the text left aligned.

    Please Help.

    Thanks,
    Mukunda

  48. Hi Mukunda,

    in this case don’t use align. Write your text left aligned as usual and use an equation environment afterwards. Since the text is not a formula, writing it into a formula line (and repairing the alignment concequences afterwards) is not meaningful.
    Though it could be fixed by rlap, makebox, mathrlap and the like, but that would not be logical.

    Stefan

  49. Hi akurye,

    if you don’t tell the error message I cannot help. Perhaps the problem has been solved. Otherwise please provide some more information.

    Stefan

  50. Hi Stefan,

    I have a problem with alignment of equations, maybe you have an idea for me?

    My problem is this: in the first line, i have a few characters, that are supposed to be followed by a certain amount of space and then a long mathematical formula, that should spread over the full line (no further columns). In the second line, there are also a few characters first, which I want aligned on the right with the ones in the first line. Then there is an equation and some conditions for the equation, i.e. two “columns”, one with the equation, one with the annotations. The next lines contain only the equations and annotations, I would like them aligned with the equation and annotation of the second line.
    Schematically, this is what its supposed to look like:

    xxxx xxxxxxxxxxxxxxxxx (1)
    xxx xxxx=xxxx xxxxx (2)
    xxxxx=xx xxx (3)
    xxx=xxx xxxx (4)

    I tried with align and then an aligned-environment inside the align. This worked tolerably for the alignemant, but then i couldn’t number and reference the lines individually, which i need sadly…

    Is there another environment, that can do what I need? Or do you have any ideas, how I might realize it with align? I’d be very thankful for any help!

    taura

  51. Uhm, well, after sending, the schematic doesn’t look like what I meant anymore. I guess, multiple spaces are killed by this editor ;-)

    I hope you can still get, what I mean by my despcription! (The = are supposed to be aligned, the xxxx in the first and xxx in the second line aligned right, and the xxxxx, xxx and xxxx in second, thrid and fourth line aligned left.)

  52. Hi Taura!

    You could use the alignat environment, it’s for aligning at several places. It’s also explained in the amsmath user’s guide.

    Stefan

  53. Thanks for the answer! I saw and tried alignat, but couldn’t find a way, to make it ignore some of the alignment for one line. That’s what I need though, because the first line is supposed to use the whole line after the first ‘&’ and ignore the alignment at the = and before the annotation, that happens in the next lines. Can alignat do that and I’m just not seeing it? Or is that in fact something, that can’t be implemented?

  54. Use makebox, rlap, llap or similar.

    For example:


    usepackage{mathtools}
    ...
    begin{alignat}{2}
    mathrlap{long math formula} ...

  55. Thanks a lot, you made my day! :-)

  56. Hi Stefan

    Is there a way of using align over normal text?

    I have 3 sections of equations with normal text in the middle, but align centres them all so the shorter ones don’t line up with the earlier ones.

    i.e.

    X = XXXXXXXXXXXXX
    Y = YYYYYYYYYYYYY

    Adaptation of this gives:

    X = XXXXX
    Y = YYYYY

    Ideally, i would like the second set to align with the first set.

    Any advice appreciated.

    Thanks

  57. Hi Reece,

    just use one align environment and escape it by \intertext:

    \begin{align}
    X &= XXXXXXXXXXXXX
    Y &= YYYYYYYYYYYYY
    \intertext{Adaptation of this gives:}
    X &= XXXXX
    Y &= YYYYY
    \end{align}
  58. Learning LaTeX is such a long journey …
    Thanks for the tips.

  59. Hello

    I have a code:

    begin{align}
    a &=blabel{eq1}\
    c &=dlabel{eq2}
    e &=flabel{eq3}
    end{align}
    See eqref{eq1} and eqref{eq2}.

    I would like to change it to system of equations with labels, for example (1a), (1b), (1c) – not (1),(2),(3). Set of equations means that it has to be started from one of { for all equations. How can we label only two selected equations (not three)?
    I look for this solution a lot of time. I have no idea. It is possible to find solution??

    Any advice appreciated. Thanks.

  60. Hi Torok,

    - you could use the subequations environment of amsmath for sub-numbering,

    - use the notag command to suppress an equation tag, just put it at the end of the line before the \.

    Stefan

  61. Hi Stefan
    Thank you for your help. I have tried with the subequations:

    begin{subequations}
    begin{empheq}[left=empheqlbrace]{align}
    a_1(x) &= b_1 label{k}\
    a_2(x) &= b_2\
    a_3(x) &= b_3
    end{empheq}
    end{subequations}
    See (ref{k})

    It is almost ideal solution. But I always have to add manual ( ) to ref.

    Thank you!

  62. Hi Torok,

    you could use eqref instead of ref. eqref is provided by amsmath.

  63. Hi Stefan,

    I use align to a long sequence of steps and sometimes I want to write a description of what was done in each step, how could put that kind of text with the align environment? with an extra & and then mbox or text?

    Thank you so much for you reply

  64. Hi Cesar,

    for in-line descriptions text would be ok, I would not use mbox. For extra alignment use extra & symbols. However, alignat instead of align might be the better choice then, for aligning at several places.

    For longer descriptions use the command intertext within the environment.

    Stefan

  65. Hi Stefan,
    I want to align two equations with mathoperators like prod_{..}^{..}. Align puts the limits behind the operator as in math formulas in the text $..$, not below and above the product symbol. Unfotunately thats quite ugly, is there a way around?

  66. Thanks for all of the answers to how to switch to align! I’ve still got one problem I can’t figure out how to solve: not all relation symbols are exactly the same width. (For example, I’m trying to use = and stackrel{rm def}{=}, but the problem presumably happens with other pairs as well.) Using eqnarray, the relation symbols were aligned at their centers; with align they have to be aligned at their left or right edges, which looks ugly. Is there a way to fix this without manually figuring out and inserting the proper amount of extra space?

    Thanks,
    -Geoff.

  67. For Adrian’s question, an answer might be to use textstyle or displaystyle (the former forces subscripts to appear after the operator, the latter above and below).

  68. Hi Geoff,

    you could use mathclap of the mathtools package, which removes the width of the argument, such as
    stackrel{mathclap{text{def}}}{=}
    I would define a macro for that.

    Stefan

  69. Hi Adrian,

    for example, int shows that behavior, in align and also in (…) and $…$. Besides displaystyle, mentioned by Geoff, you could also use limits, which affects just that operator, not more, for example:

    intlimits_a^b f(x)dx

    Stefan

  70. Thanks, great suggestion!

  71. Hi,

    I’m having trouble with the labeling of equations within the align environment.
    My code is:

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    paragraph of text here

    begin{centering}
    begin{equation}
    begin{align}
    a + b &= c + d label{mylabel1}\
    f + g &= h + k label{mylabel2}
    end{align}
    end{equation}
    end{centering}

    This sentance compares ref{mylabel1} and ref{mylabel2} …

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    When i try to compile this in latex, i get the errors:

    Package amsmath Error: Erroneous nesting of equation structures;
    (amsmath) trying to recover with `aligned’.
    end{align}
    ! Package amsmath Error: Multiple label’s: label ‘mylabel1′ will be lost.

    Looking at my document with xdvi i see the two equations labelled by only one equation number (that corresponding to mylabel2).
    The only usepackage i have loaded are amssymb and amsmath

    Does anyone know how i can retrieve both labels and refer to them in my text without simply defining two separate equation environments (which works but gives me a very large ugly space between the equations that i would like to eliminate).

    Thanks

  72. Hi Heather,

    use only align, without equation environment:

    \documentclass{article}
    \usepackage{amsmath}
    \begin{document}
    paragraph of text here
    \begin{align}
    a + b &= c + d \label{mylabel1}\\
    f + g &= h + k \label{mylabel2}
    \end{align}
    This sentance compares \ref{mylabel1}
    and \ref{mylabel2}\end{document}
  73. Hi,
    I just want to define 3 variables at the same vertical line but betas doesn’t allow to do that.
    Following commands work but beta0,beta1 and RSS are not at tht esame vertical order….

    ps: errors are missing $ or } inserted when I try to put them all into eqnarray or align etc…


    begin{displaymath}
    hat{beta_1} = frac{sum_{i=1}^n(x_i-overline x)
    (y_i-overline y)}
    {sum_{i=1}^n(x_i-overline x)^2}
    end{displaymath}
    begin{eqnarray*}
    min(RSS) & = & min{sum_{i=1}^n e_i^2} \
    & = & min{sum_{i=1}^n ({y_i- hat{y}})^2} \
    & = & min{sum_{i=1}^n [y_i-(hat{beta_0}+ hat{beta_1}x_i)]^2} \
    end{eqnarray*}

  74. Hi cagil,

    try

    \begin{document}
    \begin{align*}
      \hat{\beta_1} &= \frac{\sum_{i=1}^n(x_i-\overline x)
        (y_i-\overline y)}{\sum_{i=1}^n(x_i-\overline x)^2}\\
      \min(RSS) &= \min{\sum_{i=1}^n e_i^2} \\
        &= \min{\sum_{i=1}^n ({y_i- \hat{y}})^2} \\
        &= \min{\sum_{i=1}^n [y_i-(\hat{\beta_0}
          + \hat{\beta_1}x_i)]^2}
    \end{align*}
  75. Hello.

    I would like to ask for some help in a very simple issue: I have a list (I’m using itemize) and I want to label it just like I label an equation, for example, because I want to refer to it lately in my text.
    The reason I don’t use equation environment is that I want that it looks like a list and equation makes everything be on the center.
    The reason I don’t use flalign is that I don’t want a label for each item I want a label for the whole list.
    Thank you in advance.

  76. Hi Jackson,

    you could put the itemize list into a theorem environment. It doesn’t have to look like a theorem or definition – this is just a general way to create numbered environments, which can be referred to.

  77. I want to add nomenclature list in the middle of page of my research article, but don’t have any idea how to do it. Can anybody help me?

  78. Hi Farooq,

    you could use the nomencl package, or the glossaries package for that.

    Perhaps visit us in the LaTeX-Community.org forum, where we can discuss such LaTeX problems.

  79. Thank you Stefan

  80. I want reduce line spacing in the output of the following code, but don’t have any idea. can any body help?
    Thanks in advance.

    documentclass[12pt,runningheads,a4paper]{article}
    usepackage{amsmath}
    begin{document}

    begin{tabular}{p{0.5linewidth}p{0.5linewidth}}
    begin{description}
    item {textbf{V}} quad Velocity
    item {$rho$} quad density
    item {textbf{mbox{boldmath${tau}$}}} quad stress tensor
    item {textbf{I}} quad Unit tensor
    end{description} &
    begin{description}
    item {$eta$} quad parameter
    item {$mu$} quad viscosity
    item {p} quad pressure
    item {y} quad coordinate
    end{description}\
    end{tabular}

    end{document}

  81. Hi,

    I’m trying to use “align” to display two related equations, with a number on just the second one. But my first equation is short, while the second is long. align is right-justifying the first equation with the second, while I’d like both equations to be centered. Here’s an example of my code that isn’t working:
    begin{align}
    label{star}
    A = B nonumber \
    AAAAAAAA = BBBBBBBBBBBB
    end{align}
    Thank you!

  82. Actually, it seems that the ams “gather” works nicely to solve my simple problem above. (Also, I put the label in the wrong place).
    Thanks!

  83. Hi fkibedi!

    Yes, fortunately amsmath provides various multi-line environments with different alignment.

  84. Hi Mr. Kottwitz
    I am new with this latex stuff I dont know what will I do. You may help me. Thanks

    documentclass[a4paper,12pt]{report}
    %documentclass[a4paper, 12pt]{nigde}
    usepackage[T1]{fontenc}
    usepackage[utf8]{inputenc}
    usepackage{lmodern}
    usepackage{graphicx}
    usepackage{epstopdf}
    usepackage{thesis,moreverb,longtable,subfigure}
    usepackage{epsfig}
    usepackage{color}
    hyphenpenalty=10000
    tolerance=10000
    %usepackage{amsvath}
    % Use amstex package for special math function, like tripledot
    usepackage{amsmath}
    usepackage{caption2}
    usepackage[amsmath,thmmarks]{ntheorem}

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    I have problem with these warnings and errors

    LaTeX Warning: Reference `table:Initial Models3′ on page 42 undefined on input
    line 8.

    LaTeX Warning: Command . invalid in math mode on input line 14.

    ! Argument of T1. has an extra }.

    par
    l.14 end{flalign}
    %%%%%%%%%%%%%%%%%%%%%%%%
    Runaway argument?
    ! Paragraph ended before T1. was complete.

    par
    l.14 end{flalign}
    %%%%%%%%%%
    ?
    ! Missing $ inserted.

    $
    l.14 end{flalign}
    %%%%%%%%%%%%%%%%%%%%%%%%
    Runaway argument?
    ! Paragraph ended before T1. was complete.

    par
    l.14 end{flalign}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    ! Extra }, or forgotten $.
    }
    %%%%%%%%%%%%%%%%%%%%%%%

  85. :-) Hello Stefan, :-)

    Anna wrote you already my problem “I have a problem with align. I’d like to label each row with label{} so that I can refer to the equations individually. I get an error message that multiple labels are not possible.”, but you couldn’t help her.

    Please, could you help me to overcome this problem? :-) :-)

    begin{flalign*}
    & mbox{équations de continuité} &
    mbox{div textbf{J$_n$}} & =ee(G-R)-efrac{partial n}{partial t} & mbox{div textbf{J$_p$}} & =ee(G-R)-efrac{partial p}{partial t}label{divj}\
    & mbox{équations du courant} &
    textbf{J$_n$} & =-neemu_ntextbf{E}-ee D_ntextbf{grad}n &
    textbf{J$_p$} & =peemu_ptextbf{E}-ee D_ptextbf{grad}p label{jjj}
    end{flalign*}

    Thanking you in advance :-) :-) :-)

  86. Hello Stefan,
    I solved the problem. I have to take out the *
    Bye :-) :-) :-)

  87. Hi all,
    When I’m trying to print the following equation:
    dot{p} = dot{(C_bd)}-dot{C}_b = dot{(bar{d}-delta d)}-(bar{d}-delta d)

    I got something strange. Why the (d) in the bar disappeared? Or more precisely, it moved to be printed above the next (d).

  88. It’s very helpful for me! Thank you very much!! :D

  89. Well my problem is slightly different. The template file I am using does not allow amsmath at all and insists on eqnarray. I want the use of \begin{cases}, \text etc… BUT I dont know how to do those in eqnarray… :(

  90. I have a problem with negative equation number like (1.1. -20) and the equation numbers were repeated. how can I avoid minus sign from the lebels?

  91. I have a problem with negative equation number like (1.1. -20) and the equation numbers were repeated. how can I avoid minus sign from the lebels? may be I have large number of equation I have used eqn array is the problem?

  92. why doesn’t it assigns a number to the equation?
    Do we need more package for that?

Leave a Reply to Hussein Cancel reply

Required fields are marked *