# Force equation number to be right aligned

I'm trying to typeset some basic equations with proper numbering. I simply want a single equation to have a right aligned number in the two column environment that I'm using. I tried three approaches, but none was satisfactory. I tried the regular equation environment, which produced a number on the next line; the \mbox approach which put the number directly next to the equation (could modify with some \; padding); and the align environment which produced no number. Specifically, I have the following

\documentclass[10pt,twocolumn]{article}
\usepackage{amsmath}

\begin{document}
$$\label{NPV} \textit{NPV}_{System} = P_d+&P_{a}Y\left(\frac{1}{1+r},N\right)+C_cf_{OM}Y\left(\frac{1+i}{1+r},L\right)$$

$$\label{NPV} \mbox{\textit{NPV}_{System} = P_d+&P_{a}Y\left(\frac{1}{1+r},N\right)+C_cf_{OM}Y\left(\frac{1+i}{1+r},L\right)}$$

\begin{align}$$\label{NPV} \mbox{\textit{NPV}_{System} = P_d+&P_{a}Y\left(\frac{1}{1+r},N\right)+C_cf_{OM}Y\left(\frac{1+i}{1+r},L\right)}$$\end{align}

\end{document}


A few questions.

1. How does LaTeX determine the spacing and when to break the line (first example)?
2. Is there a way to use \mbox to right align and not just "keep together".
3. Why does \align not produce an equation number in this instance?

Some background: I'm using TeXnicCenter with LuaLaTeX though I get similar results using XeLaTeX.

• If you get errors then the pdf output should only be taken as a general debugging aid, there is no point on commenting on the alignment. Tex isn't trying to align anything just recovering from errors. You are using math constructs not in math mode and get multiple errors ! Missing $inserted. <inserted text>$ – David Carlisle Mar 12 '14 at 20:39
• (There are 35 separate TeX errors reported on that MWE before it produces a pdf file) – David Carlisle Mar 12 '14 at 20:41
• not really relevant to the question, but there shouldn't be any blank lines between the $$...$$ and similarly for align. also, the & in the equations isn't valid -- this example won't produce output, only an error log. – barbara beeton Mar 12 '14 at 20:48

You need to fix all errors before looking at the alignment, TeX's error recovery is designed to let it continue, not to make any reasonable output at the point of the error.

Your expression is just too long to fit on one line in 2 column, here are a couple of possibilities:

\documentclass[10pt,twocolumn]{article}
\usepackage{amsmath}

\begin{document}
\begin{multline} \label{NPV}
\mathit{NPV}_{\mathrm{System}} ={}\\
P_d+P_{a}Y(\frac{1}{1+r},N)+C_cf_{\mathrm{OM}}Y(\frac{1+i}{1+r},L)
\end{multline}

$$\label{NPV2} \begin{gathered} \mathit{NPV}_{\mathrm{System}} ={}\\ P_d+P_{a}Y(\frac{1}{1+r},N)+C_cf_{\mathrm{OM}}Y(\frac{1+i}{1+r},L) \end{gathered}$$
\end{document}

• Thanks for your help on this. The solution that you provided is adequate, but not optimal. I guess I don't understand why I get 35 errors - do I need to include $or$\$ in equation mode, as indicated in the error log? I'm writing a larger document that appears to handle other equations properly. Why not this one? Thanks! – Eric Morgan Mar 12 '14 at 21:00
• hard to enumerate all the things wrong in the original:-) You can not use & in equation only in alignments, you can't have blank lines in equation, \mbox takes you out of math mode, so all math constructs such as _ or \left inside the \mbox are in error, and so it goes... – David Carlisle Mar 12 '14 at 21:32
• @EricMorgan forgot to ping you on last comment:-) – David Carlisle Mar 12 '14 at 21:55
• Many thanks. Upon removal of the blank lines and ampersands the total number of errors was significantly reduced and the NPV equation in question now looks correct! – Eric Morgan Mar 12 '14 at 22:04