# how to assign equation number to the last equation only and align it to the right

\begin{align*}
\epsilon_x (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_x(i, j, k)\varphi(i + 1, j, k) + \\
\epsilon_y (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_y(i, j, k)\varphi(i + 1, j, k) +  \\
\epsilon_z (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_z(i, j, k)\varphi(i + 1, j, k) -  \\
(\epsilon_x(i - 1, j, k) + \epsilon_x(i, j, k) + \epsilon_y(i, j - 1,k) + \epsilon_y(i, j, k) \\
+ \epsilon_z(i, j, k - 1) + \epsilon_z(i, j, k))\varphi(i, j, k) + \\
h^2\lambda(i, j, k) k^2 \varphi(i, j, k) = - \frac{4\pi\rho(i, j, k)}{h} \label{eq:2}
\end{align*}


How to assign equation number to the last equation only and align it to the right?

Here is a solution using the IEEEeqnarray* environment from the IEEEtrantools package. This environment provides a tabular like syntax and it is possible to achieve most types of alignment using this environment.

The * version of the environment is used for equations without numbering. To insert an equation number in such an environment, \IEEEyesnumber command can be used.

\documentclass{article}

\usepackage{amsmath}
\usepackage{IEEEtrantools}

\begin{document}
\begin{IEEEeqnarray*}{rCl}
\IEEEeqnarraymulticol{3}{l}{\epsilon_x (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_x(i, j, k)\varphi(i + 1, j, k) +{}} \\
\IEEEeqnarraymulticol{3}{l}{\epsilon_y (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_y(i, j, k)\varphi(i + 1, j, k) +{}} \\
\IEEEeqnarraymulticol{3}{l}{\epsilon_z (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_z(i, j, k)\varphi(i + 1, j, k) -{}} \\
\IEEEeqnarraymulticol{3}{l}{(\epsilon_x(i - 1, j, k) + \epsilon_x(i, j, k) + \epsilon_y(i, j - 1,k) + \epsilon_y(i, j, k) } \\
\IEEEeqnarraymulticol{3}{l}{ {} + \epsilon_z(i, j, k - 1) + \epsilon_z(i, j, k))\varphi(i, j, k) + } \\
h^2\lambda(i, j, k) k^2 \varphi(i, j, k) &=& - \frac{4\pi\rho(i, j, k)}{h} \IEEEyesnumber\label{eq:2}
\end{IEEEeqnarray*}
\end{document}


Edit: I missed the part of your question about right alignment. Do you want something like this?

This can be achieved using only one right-aligned column.

\documentclass{article}

\usepackage{amsmath}
\usepackage{IEEEtrantools}

\begin{document}
\begin{IEEEeqnarray*}{r}
\epsilon_x (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_x(i, j, k)\varphi(i + 1, j, k) +{} \\
\epsilon_y (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_y(i, j, k)\varphi(i + 1, j, k) +{} \\
\epsilon_z (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_z(i, j, k)\varphi(i + 1, j, k) -{} \\
(\epsilon_x(i - 1, j, k) + \epsilon_x(i, j, k) + \epsilon_y(i, j - 1,k) + \epsilon_y(i, j, k) \\
{} + \epsilon_z(i, j, k - 1) + \epsilon_z(i, j, k))\varphi(i, j, k) + \\
h^2\lambda(i, j, k) k^2 \varphi(i, j, k) = - \frac{4\pi\rho(i, j, k)}{h} \IEEEyesnumber\label{eq:2}
\end{IEEEeqnarray*}
\end{document}

• thanks all for your input. all the solutions worked! Commented Feb 10, 2022 at 16:45

You could also nest an aligned[b] environment inside an equation environment. That way, a single equation number will be assigned to the entire equation, and this equation number will be placed on the bottom row.

\documentclass{article}
\usepackage{amsmath} % for 'aligned' environment

\begin{document}

\label{eq:2} \begin{aligned}[b] &\epsilon_x (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_x(i, j, k)\varphi(i + 1, j, k) \\ &\quad+ \epsilon_y (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_y(i, j, k)\varphi(i + 1, j, k) \\ &\quad+ \epsilon_z (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_z(i, j, k)\varphi(i + 1, j, k) \\ &\quad- [\epsilon_x(i - 1, j, k) + \epsilon_x(i, j, k) + \epsilon_y(i, j - 1,k) + \epsilon_y(i, j, k) \\ &\qquad+ \epsilon_z(i, j, k - 1) + \epsilon_z(i, j, k)]\varphi(i, j, k) \\ &\quad+ h^2\lambda(i, j, k) k^2 \varphi(i, j, k) = - 4\pi\rho(i, j, k)/h \end{aligned}

\end{document}


You can issue \nonumber or \notag to avoid setting a number inside an align (and friends):

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
&\hspace*{-3em}
\epsilon_x (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_x (i, j, k) \varphi(i + 1, j, k) \nonumber \\
&{} + \epsilon_y (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_y (i, j, k) \varphi(i + 1, j, k) \nonumber \\
&{} + \epsilon_z (i - 1, j, k) \varphi (i -1, j, k) + \epsilon_z (i, j, k) \varphi(i + 1, j, k) \nonumber \\
&{} - \bigl( \epsilon_x (i - 1, j, k) + \epsilon_x (i, j, k) + \epsilon_y (i, j - 1, k) + \epsilon_y(i, j, k) \nonumber \\
&{} + \epsilon_z (i, j, k - 1) + \epsilon_z(i, j, k) \bigr) \varphi(i, j, k) \nonumber \\
&\hspace*{5em} + h^2 \lambda(i, j, k) k^2 \varphi(i, j, k) = - \frac{4 \pi \rho(i, j, k)}{h}
\end{align}

\end{document}


The additional spacing elements is just for a somewhat better layout.