LaTeX forum ⇒ Math & ScienceHow to properly label two aligned equations on the same line? Topic is solved

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

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

Postby Cham » Mon Jun 11, 2018 6:43 pm

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 :

  1. \documentclass[]{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4.  
  5. Here are two funny equations :
  6. \begin{align}
  7. \label{a label}
  8. a &= b,
  9. & c &= d.
  10. \end{align}
  11. Equation \eqref{a label}a is not the same as equation \eqref{a label}b.
  12.  
  13. \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?

User avatar
Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Mon Jun 11, 2018 7:36 pm

Ok, forget it! I solved my problem simply by reformulating the text itself.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8905
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Jun 12, 2018 1:57 pm

Hi Cham,

a proper way could be using the subequations environment:

  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \begin{document}
  4. \noindent
  5. Here are two funny equations :
  6. \begin{subequations}
  7. \begin{equation}
  8. \label{eq-a}
  9. a = b
  10. \end{equation}
  11. \begin{equation}
  12. \label{eq-b}
  13. c = d
  14. \end{equation}
  15. \end{subequations}
  16. Equation \eqref{eq-a} is not the same as equation \eqref{eq-b}.
  17. \end{document}


subequation.png
subequation.png (11.68 KiB) Viewed 179 times


Stefan
Site admin

User avatar
Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Jun 12, 2018 2:03 pm

Can you place the two equations side by side, on the same line ?

User avatar
Stefan Kottwitz
Site Admin
Posts: 8905
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Jun 12, 2018 2:27 pm

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.

  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \usepackage{tabularx}
  4. \begin{document}
  5. \noindent
  6. Here are two funny equations :
  7.  
  8. \begin{subequations}
  9. \begin{tabularx}{\textwidth}{Xp{2cm}X}
  10. \begin{equation}
  11. \label{eq-a}
  12. a = b
  13. \end{equation}
  14. & &
  15. \begin{equation}
  16. \label{eq-b}
  17. c = d
  18. \end{equation}
  19. \end{tabularx}
  20. \end{subequations}
  21. Equation \eqref{eq-a} is not the same as equation \eqref{eq-b}.
  22. \end{document}


subequation-table.png
subequation-table.png (12.03 KiB) Viewed 173 times


Stefan
Site admin

User avatar
Cham
Posts: 882
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Tue Jun 12, 2018 2:47 pm

Thanks a lot for the explanations and examples. May be usefull in the future.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 1 guest