In order to be able to reference the equations in my thesis in the format like "Equation (2.2.3)" using the \autoref command I added the following lines in my preamble:
\makeatletter
\let\oldtheequation\theequation
\renewcommand\tagform@[1]{\maketag@@@{\ignorespaces#1\unskip\@@italiccorr}}
\renewcommand\theequation{(\oldtheequation)}
\makeatother
as suggested in Mico's answer in this post: autoref and braces around equation number.
This works perfectly for most of the equations but changes the format of the subequations from the standard format like "(2.3.1a)" to "(2.3.1)a". I want to keep to original format for such subequations. Namely, I want the letter to be inside the parentheses. How can I achieve this?
MWE:
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{hyperref}
\numberwithin{equation}{section}
\makeatletter
\let\oldtheequation\theequation
\renewcommand\tagform@[1]{\maketag@@@{\ignorespaces#1\unskip@@italiccorr}}
\renewcommand\theequation{(\oldtheequation)}
\makeatother
\begin{document}
\chapter{Test Chapter}
\section{Test Section}
This is a test equation two including subequations:
\begin{subequations} \label{Eq:MainEquation}
\begin{equation} \label{Eq:SubEquation1}
E = mc^2
\end{equation}
\begin{equation} \label{Eq:SubEquation2}
c^2 = a^2 + b^2
\end{equation}
\end{subequations}
As seen in \autoref{Eq:MainEquation} the labels for \autoref{Eq:SubEquation1} and \autoref{Eq:SubEquation2} are in the wrong format. The letters for the subequations should be inside the parentheses.
\end{document}


\def\equationautorefname#1#2\null{Equation#1(#2\null)}, but I'm not sure the limitations of the hack. – jessexknight Jun 09 '21 at 12:14