6

I defined the following subeqnarray

\documentclass{article}
\begin{document} 
    \begin{subeqnarray}
    & a_1+b_1=c_1, \label{eq:subeq1} \\
    & a_2+b_2=c_2, \label{eq:subeq2} \\
    & a_3+b_3=c_3. \label{eq:subeq3}
    \end{subeqnarray}
\end{document} 

How can I cite one of these equaiton, say subeq2. I used \ref{eq:subeq2}, but it gives me only one number with out b. What I want is (eq-number b). Or is there any other method to achieve my aim?

3
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Jun 17, 2015 at 15:17
  • Which package defines the environment subeqnarray?
    – Mico
    Jun 17, 2015 at 16:08
  • Hi, @ Mico, I am new to Latex. I just use \usepackage{amsmath} and \usepackage{cleveref} in the head of my document. I even don't know which package define this environment. I am sorry!
    – Enter
    Jun 18, 2015 at 1:29

2 Answers 2

4

I would not use a subeqnarray environment. Instead, I would (a) load the amsmath package and (b) nest an align environment inside a subequations environment.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "align" and "subequations" environments and "\eqref" macro
\setlength\textwidth{3in} % just for this example
\begin{document} 
\begin{subequations}
\begin{align}
    & a_1+b_1=c_1, \label{eq:subeq1} \\
    & a_2+b_2=c_2, \label{eq:subeq2} \\
    & a_3+b_3=c_3. \label{eq:subeq3}
\end{align}
\end{subequations}

A cross-reference to equation \eqref{eq:subeq1}.
\end{document} 
3
  • @ Mico, thanks. It is very close to my aim, however, in fact the lengths of my equations are very different with each other, so I want to center them instead of aligning. I have tried to remove your \begin{align} and \end{align} but it does not work.
    – Enter
    Jun 18, 2015 at 1:24
  • @lxy -- if the equations should be centered rather than aligned, just remove the three & alignment markers and replace the align environment with a gather environment.
    – Mico
    Jun 18, 2015 at 1:29
  • @ Mico, cool! :) The problem is terminated. Thank you!
    – Enter
    Jun 18, 2015 at 1:45
3

I strongly support Mico's advice in his answer about switching to one of the environments provided by amsmath. However, if you decide to keep the use of subeqnarray, you need to use \slabel instead of the standard \label command to get the proper string in the cross-references:

\documentclass{article}
\usepackage{subeqnarray}

\begin{document} 
Some cross-references to subequations~\ref{eq:subeq1}, \ref{eq:subeq2} and~\ref{eq:subeq3}.
    \begin{subeqnarray}
    & a_1+b_1=c_1, \slabel{eq:subeq1} \\
    & a_2+b_2=c_2, \slabel{eq:subeq2} \\
    & a_3+b_3=c_3. \slabel{eq:subeq3}
    \end{subeqnarray}
\end{document}

enter image description here

If, additionally, you load amsmath, then you can use \eqref to automatically get the parentheses surrounding the cross-references, but then again, if you load amsmath, switch to one of the environments it provides.

You must log in to answer this question.

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