# How to right align an equation?

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?

• Please, just don't. – Henri Menke Apr 25 '18 at 4:32
• What should this alternation mean? Is it just for academic curiosity? – egreg Apr 25 '18 at 6:41
• @egreg I really got something in which thing was right next to the equation number, but now I'm on a different machine and can't reproduce it. I'll therefore remove my comments. – user121799 Apr 25 '18 at 16:14
• @egreg I'm back home at my machine, and posted an illustration below. Either my TeXLive is broken, I am drunk, or I have a point. – user121799 Apr 25 '18 at 23:16

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]
$$\hfilneg \text{left} \hspace{10000pt minus 1fil}$$
\lipsum*[2]
$$\text{center}$$
\lipsum*[4]
$$\hspace{10000pt minus 1fil} \text{right} \hfilneg$$
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}


• I was thinking about separating the equation in 2 environments, however, as you predicted, multiline did the job. – Vitor Abella Apr 25 '18 at 19:04

NOT AN ANSWER. Hello @egreg, when I compile

\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{flalign}
left
\end{flalign}
$$\hfill right$$
\end{document}


I get

• Using \mathleft to get right alignment is cheating! ;-) – egreg Apr 26 '18 at 8:27
• @egreg This was already in the OP's code. So I made the comment that (s)he could use \hfill, and tested it before. And what's wrong with cheating? ;-) – user121799 Apr 26 '18 at 8:53