MHB How to left align the \align environment

  • Thread starter Thread starter rapid1
  • Start date Start date
AI Thread Summary
To left-align a specific LaTeX align environment without affecting others, the aligned environment can be utilized, which generates an hbox instead of a vbox. This allows for the insertion of the aligned content anywhere in the document. A custom command, \leftdisplay, can be defined to achieve this. The command uses \makebox to set the alignment to the left while allowing for the inclusion of the aligned equations. Additionally, an indent can be added for further adjustment. This method provides a flexible solution for left-aligning specific equations in LaTeX documents.
rapid1
Messages
13
Reaction score
0
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.
 
Physics news on Phys.org
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.
 
Back
Top