# Referencing the subequations block doesn't show the section number

I am new to this stackexchange group so forgive me if my question is not proper. If some extra information is required then kindly comment, I will attach those details.

I am using the following lines

\begin{subequations}
\renewcommand{\theequation}{\arabic{section}.\theparentequation.\arabic{equation}}
\begin{align}
& y = (c-r_x)*x + r_x*gbest, \label{eq:0.1} \\
& y = (c-r_n)*x - r_n*gbest, \label{eq:0.2} \\
\end{align}
\label{eq:eqn}
\end{subequations}


But calling \cref{eq:eqn} prints eq.(1) instead of eq(.1). This doesn't happen when I am referencing the subequations. Can someone please guide me on how to achieve this?

• Welcome to TeX.SE.
– Mico
Mar 14 at 8:02
• Please clarify the meaning of \cerf. Is it maybe a typo and should say \cref, which is a macro provided by the cleveref package? Please also tell us which document class you employ.
– Mico
Mar 14 at 8:02
• Please provide a minimal working example (MSE). Mar 14 at 11:56

You should use \numberwithin{equation}{section} in the preamble instead of putting \thesection inside \theequation.

\documentclass{article}
\usepackage{amsmath}
\usepackage{cleveref}
\numberwithin{equation}{section}
\begin{document}
\section{TEST}

Intro

\begin{subequations}
\renewcommand{\theequation}{\theparentequation.\arabic{equation}}
\begin{align}
& y = (c-r_x)*x + r_x*gbest, \label{eq:0.1} \\
& y = (c-r_n)*x - r_n*gbest, \label{eq:0.2}
\end{align}
\label{eq:eqn}
\end{subequations}

And then refer to equation \ref{eq:0.2}, which is within \cref{eq:eqn}.
\end{document}


Something like this?

\documentclass{article}
\usepackage{amsmath,cleveref}
\numberwithin{equation}{section}

\begin{document}
\setcounter{section}{3} % just for this example
\begin{subequations}
\renewcommand{\theequation}{\theparentequation.\arabic{equation}}
\begin{align}
y_x &= (c-r_x)x + r_x g_{\mathrm{best}}, \label{eq:0.1} \\
y_n &= (c-r_n)x - r_n g_{\mathrm{best}}  \label{eq:0.2}
\end{align}
\label{eq:eqn}
\end{subequations}
\verb|\cref{eq:eqn} and \cref{eq:0.1}| produces
\cref{eq:eqn} and \cref{eq:0.1}''.
\end{document}