0
  1. The code below gives me ?? when referencing the equations. How do i fix it ?

  2. How do I get (1a,1b) for the first equation if possible?

MWE

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

\begin{gather}
f: A \to B, g: B \to C \label{eq:1} \\
\begin{aligned}
f(a) &= \ldots \label{eq:2} \\
g(b) &= \ldots \label{eq:3}
\end{aligned}
\end{gather}

\ref{eq:1} \ref{eq:2} \ref{eq:3}

\end{document}

enter image description here

4
  • 1
    as your output shows, rows of aligned to not get separate numbers, so can not have separate labels Commented May 3, 2023 at 15:32
  • You can achieve your second point by wrapping environment subequations from amsmath around the respective gather, align or equation environments. Or did you mean to ask for numbering these three lines into "(1)", "(1a)" and "(1b)" ?
    – marc
    Commented May 3, 2023 at 16:01
  • thank you, i meant that i would like to split (1) into (1a,1b) since there are 2 equations in line 1.
    – Kong
    Commented May 3, 2023 at 16:09
  • 1
    Please only ask one question at a time. It seems that you should make more clear what you would like to achieve. Commented May 4, 2023 at 1:26

1 Answer 1

2

enter image description here

It is then better to use align. If you do not want the first equation to be aligned with the others, then it is possible to use \mathclap from mathtools package

Off-topic: cross referencing is better handled with cleveref package

\documentclass{article}

\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{cleveref}

\begin{document}
    
    \begin{align}
        & \mathclap{f: A \to B, g: B \to C} \label{eq:1}
        \\
        f(a) &= \ldots \label{eq:2}
        \\
        g(b) &= \ldots \label{eq:3}
    \end{align}
    
    \cref{eq:1,eq:2,eq:3}
    
    \ref{eq:1} \ref{eq:2} \ref{eq:3}
    
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .