Math & ScienceAlign Equations with different Label

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
aitorp
Posts: 2
Joined: Wed Feb 06, 2013 11:43 am

Align Equations with different Label

Post by aitorp »

Hello,

I have some equations that I would like to show aligned. However, I want to gather them in two groups, so I can make a reference to the first group, or to the second group (a single equation in this case).

I would like to do the next, but with the last equation aligned to the previous 4.

Code: Select all

\begin{subequations}\label{eq_1}
  \begin{align}
    m_{i}'=&0  \quad m_{ij}=m_{i} \\
    mx_{j}'=&0 \quad m_{ij}=-\frac{1}{\lambda_j\cos\alpha_j}\cdot mx_j \\
    my_{j}'=&0 \quad m_{ij}=-\frac{1}{\lambda_j\sin\alpha_j}\cdot my_j \\
    J_{j}'=&0  \quad m_{ij}=-\frac{1}{\lambda_j^2} \cdot J_j
  \end{align}
\end{subequations}

\begin{equation}\label{eq_2}
  m_{j}'=0  \quad\Longrightarrow\quad m_{ij}=-m_j
\end{equation}

Thank you in advance,

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

Align Equations with different Label

Post by localghost »

With a trick you can put all equations into one align (or alignat) and subequations environment and still have different labels. And this trick is to explicitly set a \tag for the last equation that replaces the automatic numbering. But you have to increment the equation counter manually right after the subequations environment to get a correct numbering for all following equations.

Code: Select all

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

\begin{document}
  \begin{subequations}\label{eq:1}
    \begin{alignat}{2}
      m_{i}' &=0   & m_{ij} &= m_{i} \label{sub-eq-1:1}\\
      mx_{j}' &=0  & m_{ij} &= -\frac{1}{\lambda_j\cos\alpha_j}\cdot mx_j \label{sub-eq-2:1} \\
      my_{j}' &= 0 & m_{ij} &= -\frac{1}{\lambda_j\sin\alpha_j}\cdot my_j \label{sub-eq-3:1} \\
      J_{j}' &= 0  & m_{ij} &= -\frac{1}{\lambda_j^2} \cdot J_j \label{sub-eq-4:1} \\
      m_{j}' &= 0  &\quad\Longrightarrow\quad m_{ij} &= -m_j \tag{2}\label{eq:2}
    \end{alignat}
  \end{subequations}
  \stepcounter{equation}

  Reference to \eqref{eq:1} with sub-equations \eqref{sub-eq-1:1}--\eqref{sub-eq-4:1} and \eqref{eq:2}.
\end{document}
As you can see, even the common \eqref command works without a problem. The alignat environment has been used to get more control over the alignment.


Further reading:

Best regards and welcome to the board
Thorsten
Attachments
subequations-equation-alignment.png
subequations-equation-alignment.png (17.44 KiB) Viewed 26588 times
aitorp
Posts: 2
Joined: Wed Feb 06, 2013 11:43 am

Re: Align Equations with different Label

Post by aitorp »

OK, thank you very much, it's really useful

But, is there any trick to increment the equation counter automatically?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Align Equations with different Label

Post by localghost »

aitorp wrote:[…] is there any trick to increment the equation counter automatically?
Not that I'm aware of. You would have to implement it yourself.
Post Reply