19

I've looked around at various sites and tried switching between array/eqnarray but don't seem to be able to get the effect I would like. I want to simply give an array I have one single equation number. I would also like to know just to make sure, how to give each equation a number within an array.

The equation I have is the following:

$$
\begin{array}{lr}
N_{x,sk} = k_{sk}\left(\frac{t_{sk}}{b_{sk}}\right)^{2}\bar{Et} \;\;
N_{x,st} = k_{st}\left(\frac{t_{st}}{b_{st}}\right)^{2}\bar{Et}
\end{array}
$$

Could someone please help provide examples where I would have these equations showing one equation number and then also an example with two separate ones please?

0

2 Answers 2

12

Using the eqnarray environment instead of array, you can add \nonumber to any lines you don't want numbered. If you don't do this, every line will be numbered.

\begin{eqnarray}
N_{x,sk} &=& k_{sk}\left(\frac{t_{sk}}{b_{sk}}\right)^{2}\bar{Et} \nonumber \\
N_{x,st} &=& k_{st}\left(\frac{t_{st}}{b_{st}}\right)^{2}\bar{Et}
\end{eqnarray}

(Just remove the \nonumber from the above to get the second example.)

2
  • Agreed. In the answer, I use eqnarray as the "vanilla" built-in multi-line equation alignment environment, but align, IEEEeqnarray, etc. are much better choices in general.
    – ezod
    Commented Nov 18, 2012 at 21:06
  • 1
    Please consider reading Peter Grill's answer, as use of eqnarray is not recommended.
    – user2473
    Commented Nov 20, 2012 at 2:34
22

I would recommend you use the equation environment if you want a single equation for an entire array.

However, since this construct does not really seem to need an array, I would recommend using the align environment from the amsmath package, with which you can use \nonumber to selectively disable an equation number.

enter image description here

Notes:

  • Use of eqnarray is not recommended as per \eqnarray vs \align.

  • Also you should not use double dollar signs for display math as per Why is \[ … \] preferable to $$?

  • The math spacing in you array example was not correct. This has been corrected in the example below.

References:

Code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}\noindent
Using \verb|equation| with \verb|array|:
\begin{equation}
\begin{array}{r@{}l}
    N_{x,sk} &{}= k_{sk}\left(\frac{t_{sk}}{b_{sk}}\right)^{2}\bar{Et}\\
    N_{x,st} &{}= k_{st}\left(\frac{t_{st}}{b_{st}}\right)^{2}\bar{Et}
\end{array}
\end{equation}
%
Using \verb|align|:
\begin{align}
    N_{x,sk} &= k_{sk}\left(\frac{t_{sk}}{b_{sk}}\right)^{2}\bar{Et}\\
    N_{x,st} &= k_{st}\left(\frac{t_{st}}{b_{st}}\right)^{2}\bar{Et}
\end{align}
%
Using \verb|align| with \verb|\nonumber|:
\begin{align}
    N_{x,sk} &= k_{sk}\left(\frac{t_{sk}}{b_{sk}}\right)^{2}\bar{Et}\nonumber\\
    N_{x,st} &= k_{st}\left(\frac{t_{st}}{b_{st}}\right)^{2}\bar{Et}
\end{align}
\end{document}
5
  • 2
    What does {r@{}l} exactly mean in \begin{array}{r@{}l} ?
    – NumberFour
    Commented Jul 4, 2015 at 11:34
  • 3
    @NumberFour: @{} eliminates the inter column spacing that is usually there with tabular and array. Try removing it to see the difference. The r and l set the columns to be left and right aligned. Commented Jul 4, 2015 at 23:26
  • Is this still the best way to do this -- using equation and array? How would you allow for natural spacing of fractions? My fractions, integrals, etc that are generally larger are getting squished to one line making them hard to read using the equation and array as in the first example. Commented Feb 5, 2019 at 7:09
  • 1
    @EricBringley: Without seeing the specific issue you are referring to it is hard to give you advice. I would suggest you ask a new question (and reference this one if it is relevant) and include fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. Commented Feb 5, 2019 at 7:18
  • Sorry, @PeterGrill. Will continue browsing other questions before opening a new question. Thanks for the reply. Commented Feb 5, 2019 at 10:22

You must log in to answer this question.

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