# Changing the format of figure, algorithm and equation numbering [duplicate]

This is a follow-up to this question. That allowed me to format references to an equation/figure/algorithm so that they started with an 'S'. What if I want to change the format in the original equation/figure/algorithm? For instance, if I entered

$$a=b \label{eq:myeq}$$


How would I get it to show up in the final document as:

a=b (S1)


a=b (1)


?

\def\theequation{S\arabic{equation}}


I assume that you use it in article. Definition for report or book should be a bit modified.

MWE:

\documentclass{article}
\begin{document}

\def\theequation{S\arabic{equation}}

$$2+2=4$$

\end{document}