\documentclass[12pt, a4paper]{report}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage[ruled]{algorithm2e}
\begin{document}
\begin{algorithm}
\caption{my capt}
\begin{minipage}{\dimexpr\textwidth-2\algomargin\relax}
\begin{enumerate}
\item step 1
\item step 2
\item step 3
\begin{equation}\label{alg1}
\tau = x + y.
\end{equation}
\item step 5
\end{enumerate}
\end{minipage}
\end{algorithm}
I have an equation:
\begin{equation}\label{myeq}
\alpha = x^2 y.
\end{equation}
\end{document}
Here in the above MWE, I use a minipage environment to avoid getting an overfull hbox error. I want to align the equation numbers vertically inside and outside the algorithm. It looks like in the figure below. I want to align equations (1) and (2):
How can I do that?
This question is very similar to the one posted here: https://tex.stackexchange.com/a/460466/139314 Instead of a box, I have an algorithm environment.
Many thanks in advance.


\item[](itemize instead of enumerate). – John Kormylo Feb 01 '22 at 15:35