[Tex/LaTex] Writing an equation with the units positioned off right

equationsformattingunits

Okay so I have a have a lot of equations in the document I am writing and I am trying to display the units of an equation off to the right. I was wondering how I can achieve this? Right now, all I can do is write the equation with the units attached at the end. Here is my code:

\usepackage{amsmath, siunitx}
\begin{document}

        \begin{equation}
            {
            I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}}             [\si{\watt\per\meter\squared}]          
            }
        \label{eq:PeakIntensity}
        \end{equation}

    Where

        \begin{equation}
            {
            E_p \equiv \frac{P}{R}          [\si{\joule}]
                    }
        \label{eq:PulseEnergy}
        \end{equation} 

\end{document}

Thanks for any and all help!

edit: One more thing while I have this posted! I'm sure this is simple, but how do I also display the equation number on the far right of the page so I can reference equations later? Thanks!

Best Answer

Adding the information directly into \tag as in another answer is a bad idea, since the added material will also appear in cross-references, which clearly is undesired.

Here's another option producing the right result for cross-references;

\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{detect-all}

\makeatletter
\providecommand\add@text{}
\newcommand\tagaddtext[1]{%
  \gdef\add@text{#1\gdef\add@text{}}}% 
\renewcommand\tagform@[1]{%
  \maketag@@@{\llap{\add@text\quad}(\ignorespaces#1\unskip\@@italiccorr)}%
}
\makeatother

\begin{document}

As we see in Equations~\eqref{eq:PeakIntensity} and~\eqref{eq:PulseEnergy}...

\begin{equation}
\label{eq:PeakIntensity}
I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}}   
\tagaddtext{[\si{\watt\per\meter\squared}]}
\end{equation}    
Where    
\begin{equation}
\label{eq:PulseEnergy}
E_p \equiv \frac{P}{R}
\tagaddtext{[\si{\joule}]}
\end{equation}

\end{document}

enter image description here

The \tagaddtext macro is a variation of Werner's definition in his answer to Numbered equations with additional text part 2.