Text FormattingHow to automatically number align command

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
cvanloon
Posts: 6
Joined: Wed Jun 08, 2011 5:38 pm

How to automatically number align command

Post by cvanloon »

I am new to latex and am having a hard time with the automatic numbering here is my situation:
  1. I have a long equation that needs to have multiple lines. I used the align* environment to fix that.
  2. Once I had it aligned the way I wanted it, I wanted it to automatically number it like the equation environment.
  3. I used the align environment instead of the align*, and had it automatically number each line of the equation.
I understand that I could use the tag command, but what if the number changes in the future. Any help is appreciated. Thanks,

Chris

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to automatically number align command

Post by localghost »

If the problem is to have only one single number, try this approach.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}   % loads »amsmath«

\begin{document}
  \begin{equation}\label{eqn:binomi}
    \begin{aligned}
      (a+b)^2 &= a^2+2ab+b^2 \\
      (a-b)^2 &= a^2-2ab+b^2 \\
      (a+b)(a-b) &= a^2-b^2
    \end{aligned}
  \end{equation}
\end{document}
The amsmath manual has the details.


Best regards and welcome to the board
Thorsten
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

How to automatically number align command

Post by Stefan Kottwitz »

Hi Chris,

besides aligned, you could also use the split environment. It works in Thorstens example with exactly the same syntax.

Stefan
LaTeX.org admin
Post Reply