[Tex/LaTex] How to insert words into equation numbering

equationsnumbering

I would like to produce equations that have numbers on the right hand side in the style of (eqn 1) rather (1). How would I do this, presumably using a user defined command, but I am having trouble with it.

Example

x + y = 2 (eqn 1)

y = 5 + 4 (eqn 2)

Best Answer

You can go a simple way with

\renewcommand{\theequation}{eqn \arabic{equation}}

or with a fancier approach (see How to move amsmath equation label into LHS margin? for motivation)

\documentclass{article}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
% detach \eqref processing from \tag processing
\let\tagform@ref\tagform@
\let\maketag@@@ref\maketag@@@
\patchcmd{\eqref}{\tagform@}{\tagform@ref}{}{}
\patchcmd{\tagform@ref}{\maketag@@@}{\maketag@@@ref}{}{}
% redefine \tagform@ to have “eqn” in front of the number
\def\tagform@#1{%
  \maketag@@@{(\ignorespaces eqn #1\unskip\@@italiccorr)}%
}
\makeatother

\begin{document}

We reference equation~\eqref{a} which follows
\begin{align}
x + y &= 2 \label{a}\\
y     &= 5 + 4
\end{align}
\end{document}

enter image description here