Math & ScienceNumber each row in an array?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
CaptainProton
Posts: 15
Joined: Fri Dec 18, 2009 10:54 pm

Number each row in an array?

Post by CaptainProton »

I would like to number each (or at least some) row in an array-environment. How can I do this?

The reason why I'm not using a align-environment is that I want to have the top- and bottomrules of the booktabs class. Maybe there is another solution?

My working example (note that the array as a whole gets an equation numer):

Code: Select all

\documentclass{scrreprt}
\usepackage{booktabs}

\begin{document}
  \begin{equation}
    \begin{array}{rl}
      \toprule
      x^2 + y^2 &= z^2\\
      x^2       &= z^2 - y^2\\
      \bottomrule
    \end{array}
  \end{equation}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Number each row in an array?

Post by gmedina »

Hi,

Code: Select all

\documentclass{scrreprt}
\usepackage{booktabs,array}

\newcounter{myrow}

\begin{document}
  \begin{equation}
    \begin{array}{>{\stepcounter{myrow}\themyrow}lrl}
      \toprule
      & x^2 + y^2 &= z^2\\
      & x^2       &= z^2 - y^2\\
      \bottomrule
    \end{array}
  \end{equation}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
CaptainProton
Posts: 15
Joined: Fri Dec 18, 2009 10:54 pm

Re: Number each row in an array?

Post by CaptainProton »

Wow, that's a nice trick! However, I don't want to create my own equation numbers but use the built-in numbering -- just as if these equations stood in an {align}-environment instead of an array.
Post Reply