Welcome to our community

Be a part of something great, join today!

MathJax How to left align the \align environment

rapid

New member
Jan 31, 2012
13
Hi there,

I have the following bit of latex
Code:
\begin{align*} [a,\; b] & = \{x;\; a\leq x\leq b\}\\
(a,\; b) & = \{x;\; a < x < b\}\\
\mathrm{[}a,\; b) & = \{x;\; a\leq x < b\}\\
(a,\; b\mathrm{]} & = \{x;\; a < x \leq b\}\\
\end{align*}
However it is centered. Is there a left equivalent of \centering or is there another way to get this \align environment left aligned in my document.

Anything that gets it left would be excellent although I don't want anything that will set all \aligns left, just this one.

Thanks.
 

Evgeny.Makarov

Well-known member
MHB Math Scholar
Jan 30, 2012
2,492
You can use the environment aligned, which is like align* but generates an hbox instead of a vbox (i.e., it does not add a new line to the text but instead generates a rectangle that can be inserted anywhere a letter can). After that, you can design your own line and insert this hbox where you need it (left, center or right).

E.g., you can have the following definition.

Code:
\newcommand{\leftdisplay}[1]{\[\makebox[\textwidth][l]{$\displaystyle #1$}\]}
and then say

Code:
\leftdisplay{
\begin{aligned}\relax [a,\; b] & = \{x;\; a\leq x\leq b\}\\
(a,\; b) & = \{x;\; a < x < b\}\\
\mathrm{[}a,\; b) & = \{x;\; a\leq x < b\}\\
(a,\; b\mathrm{]} & = \{x;\; a < x \leq b\}
\end{aligned}}
You can insert \indent before $\$$ in \leftdisplay to shift the formula a bit to the right.

See also exercise 19.4 in Knuth's The TeXbook.