# How do I align a math environment to the right?

I'm trying to wrote a few math formulas, but they go left. The picture will explain:

As you can see, the < signs are not in the same line. The code:

צד ראשון: \L{
\begin{eqnarray*}
2(i+1) & \leq & j+2\\
2i+2 & \leq & j+2\\
2i & \leq & j
\end{eqnarray*}
}צד שני:\L{
\begin{eqnarray*}
j+2 & \leq & 3(i+1)\\
j+2 & \leq & 3i+3\\
j & \leq & 3i+1
\end{eqnarray*}


I'm using LyX, anyone know how to fix it? Thanks!

• eqnarray only aligns the symbols within the same display, the first one has larger formula on the left hand side. – David Carlisle May 18 '19 at 16:58
• Note it is impossible for anyone to run your code to debug any issues as you provide no document, and no definition for \L (also it is better to use amsmath evironment align* rather than eqnarray* – David Carlisle May 18 '19 at 17:00

The following works for me in LuaLaTeX:

\documentclass{article}
\usepackage[bidi=basic]{babel}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{libertinus}
% To make the output narrow enough to fit on TeX.SX:
\usepackage[paperwidth=11cm]{geometry}

\babelprovide[main, import=he]{hebrew}

\begin{document}
צד ראשון:
\begin{align*}
2(i+1) & \leq & j+2\\
2i+2 & \leq & j+2\\
2i & \leq & j
\end{align*}

צד שני:
\begin{align*}
j+2 & \leq & 3(i+1)\\
j+2 & \leq & 3i+3\\
j & \leq & 3i+1
\end{align*}
\end{document}


Or at least, this aligns the equations to the right as you wanted. I would probably tweak the alignment a bit:

\documentclass{article}
\usepackage[bidi=basic]{babel}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{libertinus}
% To make the output narrow enough to fit on TeX.SX:
\usepackage[paperwidth=11cm]{geometry}

\babelprovide[main, import=he]{hebrew}

\begin{document}
צד ראשון:
\begin{align*}
2(i+1) & \leq j+2\\
2i+2 & \leq j+2\\
2i & \leq j
\end{align*}

צד שני:
\begin{align*}
j+2 & \leq 3(i+1)\\
j+2 & \leq 3i+3\\
j & \leq 3i+1
\end{align*}
\end{document}


Both of these samples use the bidi feature of babel to align the equation blocks correctly for Hebrew, and the align* environment of mathtools. They also load a font family with Unicode support for both Hebrew text and math.

See also this question for another way to flush equations to the right, and this one to align equations in two separate blocks.

You might consider adding the option \usepackage[leqno]{mathtools} if you want equation numbers to the left.