Math & ScienceHow to properly label two aligned equations on the same line?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to properly label two aligned equations on the same line?

Post by Cham »

I rarely do the following (it's the first time, actually!). To save space on a page, I have to align two labeled equations on the same line. Then I need to make a reference to these equations in the text. The MWE below reproduce the issue :

Code: Select all

\documentclass[]{article}
\usepackage{amsmath}
\begin{document}

Here are two funny equations :
	\begin{align}
	\label{a label}
		a &= b,
		& c &= d.
	\end{align}
Equation \eqref{a label}a is not the same as equation \eqref{a label}b.

\end{document}
I need the equation numbers to be properly shown as (1a) and (1b), not as (1)a and (2)b like what is done by hand in this code. What should be the proper way of doing this?

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
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to properly label two aligned equations on the same line?

Post by Cham »

Ok, forget it! I solved my problem simply by reformulating the text itself.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

How to properly label two aligned equations on the same line?

Post by Stefan Kottwitz »

Hi Cham,

a proper way could be using the subequations environment:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent
Here are two funny equations :
\begin{subequations}
  \begin{equation}
    \label{eq-a}
      a = b
  \end{equation}
  \begin{equation}
    \label{eq-b}
    c = d
  \end{equation}
\end{subequations}
Equation \eqref{eq-a} is not the same as equation \eqref{eq-b}. 
\end{document}
subequation.png
subequation.png (11.68 KiB) Viewed 64910 times
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to properly label two aligned equations on the same line?

Post by Cham »

Can you place the two equations side by side, on the same line ?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

How to properly label two aligned equations on the same line?

Post by Stefan Kottwitz »

There's support for side by side and alignment in general, just mixing in sub-numbering in aligned environments is not so common and less supported by default. For example, there cannot be several labels for references in the same align environment line.

But it's easy doing it with \parbox or \minipage and in the same way above. Or here, I simply use tabularx, the X columns share the available space symmetrically, in the middle I just have a column for separation space. It's not so unusual: for arranging stuff in columns, a table is a natural choice.

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularx}
\begin{document}
\noindent
Here are two funny equations :

\begin{subequations}
  \begin{tabularx}{\textwidth}{Xp{2cm}X}
  \begin{equation}
    \label{eq-a}
      a = b
  \end{equation}
  & &
  \begin{equation}
    \label{eq-b}
    c = d
  \end{equation}
  \end{tabularx}
\end{subequations}
Equation \eqref{eq-a} is not the same as equation \eqref{eq-b}. 
\end{document}
subequation-table.png
subequation-table.png (12.03 KiB) Viewed 64904 times
Stefan
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

How to properly label two aligned equations on the same line?

Post by Cham »

Thanks a lot for the explanations and examples. May be usefull in the future.
JoshuaHampton
Posts: 1
Joined: Thu Dec 28, 2017 10:35 am

How to properly label two aligned equations on the same line?

Post by JoshuaHampton »

The amsmath package provides a handful of options for displaying equations. You can choose the layout that better suits your document, even if the equations are really long, or if you have to include several equations in the same line.

Contents
1 Introduction
2 Including the amsmath package
3 Writing a single equation
4 Displaying long equations
5 Splitting and aligning an equation
6 Aligning several equations
7 Grouping and centering equations
8 Further reading
Post Reply