Align – How to Right Align an Equation in LaTeX

align

I have an equation and i want to right align it:

\documentclass{report}
\usepackage{amsmath,amsfonts,amsthm,bm} %math

%----------------------------------------
%Align Equations to LEFT MARGIN (use \mathleft then \mathcenter)
\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother
%----------------------------------------

\begin{document}
\begin{align}
center
\end{align}
\mathleft
\begin{align}
left
\end{align}
\end{document}

I have an awesome piece of code that allows me to leftalign with \mathleft, is it possible to have one that right align?

enter image description here

Best Answer

Of course you can, though not without reading the TeXbook (Exercise 19.8). Look at the final example, though, which could be what you're looking for.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum}

\begin{document}

\lipsum*[2]
\begin{equation}
\hfilneg \text{left} \hspace{10000pt minus 1fil}
\end{equation}
\lipsum*[2]
\begin{equation}
\text{center}
\end{equation}
\lipsum*[4]
\begin{equation}
\hspace{10000pt minus 1fil} \text{right} \hfilneg
\end{equation}
But I guess you want something like this final example,
because ``right aligning'' equations has generally no
use:
\begin{multline}
\text{the first part of a very long equation,
      that is set flush left} \\
\text{the final part, also quite long, set flush right}
\end{multline}

\end{document}

enter image description here