Writing an equation with the units positioned off right

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.


A solution with flalign and a variant, that use the original counters. I use a macro called \unit (resp. \varunit) that place the unit at a small distance from the equation number. The difference is that the equations are centred with respect the space that remains between the left margin and the unit, while for the variant it is centred with respect to the leftmargin and the em space before the equation number. It's only a matter of aesthetic choice.

    \documentclass[11pt, a4paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern, amssymb, amsfonts}
    \usepackage{mathtools}
    \usepackage{siunitx} 
    \newcommand*\unit[1]{&  & \si{[#1]}\quad}
    \newcommand*\varunit[1]{& \llap{\si{[#1]}}&\quad}
    \begin{document}

    \begin{flalign}
         &  &  I_0 & \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}} \unit{\watt\per\meter\squared}%
    \label{eq:PeakIntensity}
    \shortintertext{ Where}
      &  &    E_p  & \equiv \frac{P}{R}     \unit{\joule}
       \label{eq:PulseEnergy}
    \end{flalign}
    \bigskip

    \textbf{Variant:}  
    \begin{flalign}
         &  &  I_0 & \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}}   \varunit{\watt\per\meter\squared}
    \label{eq:PeakIntensity}
    \shortintertext{ Where}
      &  &    E_p  & \equiv \frac{P}{R}       \varunit{\joule}
       \label{eq:PulseEnergy}
    \end{flalign}
    \end{document}

enter image description here If you do not want to align the \equiv signs, you just have to use 2 flalign environments.


My suggestion is simply not typesetting the unit, because units are not invariants, while the formula is. So you have E_p=P/R (maybe with some constant around) even if your energy was measured in ergs or other units. That I_0 is in watt per squared meter is already obvious from the what's said when the quantity was being defined. Note also that square brackets are used to denote physical dimensions, while a joule is a physical quantity.

This said, you have some choices:

  1. no unit
  2. the unit typeset at a fixed distance from the equation number (with flalign)
  3. the unit typeset at a fixed distance from the equation, participating to the centering
  4. the unit typeset at a fixed distance from the equation, not participating to the centering

In the example, I don't show the first (recommended) choice. Note that the last one may cause overlaps if the formula is long.

\documentclass{article}
\usepackage{mathtools, siunitx}
\begin{document}

Some text above
\begin{flalign}
  &&&I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}},
  &&(\si{\watt\per\meter\squared})
  \label{eq:PeakIntensity}
\end{flalign}
where
\begin{flalign}
  &&&E_p \equiv \frac{P}{R}.
  &&(\si{\joule})
  \label{eq:PulseEnergy}
\end{flalign} 

Some text above
\begin{equation}
  I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}},
  \qquad (\si{\watt\per\meter\squared})
  \label{eq:PeakIntensity2}
\end{equation}
where
\begin{equation}
  E_p \equiv \frac{P}{R}.
  \qquad (\si{\joule})
  \label{eq:PulseEnergy2}
\end{equation} 

Some text above
\begin{equation}
  I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}},
  \mathrlap{\qquad (\si{\watt\per\meter\squared})}
  \label{eq:PeakIntensity3}
\end{equation}
where
\begin{equation}
  E_p \equiv \frac{P}{R}.
  \mathrlap{\qquad (\si{\joule})}
  \label{eq:PulseEnergy3}
\end{equation} 

\end{document}

Note also that mathtools is used for \mathrlap; it automatically loads amsmath.

enter image description here


A modification of Gonzalo's answer, that won't have the defect that the equation can overlap the unit.

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

\makeatletter
%%% redefine \eqref to be like the original
\renewcommand{\eqref}[1]{\textup{\eqreftagform@{\ref{#1}}}}
\let\eqreftagform@\tagform@
%%% redefine \tagform@
\def\tagform@#1{%
  \maketag@@@{%
    \if@unit(\thiseq@unit)\quad\fi\global\@unitfalse
    (\ignorespaces#1\unskip\@@italiccorr)%
  }%
}
\newif\if@unit
\def\equnit#1{%
  \gdef\thiseq@unit{#1}%
  \global\@unittrue
}
\makeatother

\begin{document}

\begin{equation}            
I_0 \equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}},
\equnit{\si{\watt\per\meter\squared}}
\label{eq:PeakIntensity}
\end{equation}
where
\begin{equation}            
E_p \equiv \frac{P}{R}.
\equnit{\si{\joule}}
\label{eq:PulseEnergy}
\end{equation}
Let's see with \texttt{align}:
\begin{align}
I_0 &\equiv \frac{4E_p}{{\tau}{w_{0}^{2}}\pi\sqrt{2\pi}},
\equnit{\si{\watt\per\meter\squared}}
\label{eq:PeakIntensity2}\\
E_p &\equiv \frac{P}{R}.
\equnit{\si{\joule}}
\label{eq:PulseEnergy2}
\end{align}
An equation without unit:
\begin{equation}
1=1
\end{equation}
A long equation with unit:
\begin{equation}
aaaaaaaaaaaaaaaaaaaaaaa=bbbbbbbbbbbbbbbbbbbb+ccccccccccccccc
\equnit{\si{\joule}}
\end{equation}
A longer equation with unit:
\begin{equation}
aaaaaaaaaaaaaaaaaaaaaaa=bbbbbbbbbbbbbbbbbbbb+cccccccccccc+ddddddd
\equnit{\si{\joule}}
\end{equation}
The references: \eqref{eq:PeakIntensity} and \eqref{eq:PulseEnergy};
\eqref{eq:PeakIntensity2} and \eqref{eq:PulseEnergy2}.
\end{document}

enter image description here