How to left align the \align environment

  • MHB
  • Thread starter rapid1
  • Start date
In summary, the conversation discusses the use of the aligned environment in LaTeX to left align the \align* environment. The solution involves using the aligned environment and creating a custom line using the \newcommand function. This allows for the left alignment of specific equations without affecting all \align* environments in the document. The conversation also suggests referencing exercise 19.4 in Knuth's The TeXbook for further guidance.
  • #1
rapid1
13
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
  • #2
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.
 

FAQ: How to left align the \align environment

How do I left align the equations in the align environment?

To left align the equations in the align environment, you can use the fleqn option in the documentclass or use the flalign environment instead of align. You can also use the align* environment and add & at the beginning of each line to align the equations to the left.

Can I left align only certain equations in the align environment?

Yes, you can use the flalign environment and add & at the beginning of each line that you want to left align. For the remaining equations, you can use the regular align environment.

How do I set the alignment to left for all equations in the align environment?

You can use the fleqn option in the documentclass or use the flalign environment instead of align. You can also use the align* environment and add & at the beginning of each line to align all equations to the left.

What do I do if my equations are still not left aligned after using the suggested methods?

If your equations are still not left aligned, it could be due to conflicting packages or settings in your document. Try removing any custom alignments or packages that may be affecting the alignment of your equations.

Is there a way to left align equations without using any special environments or options?

Yes, you can use the align* environment and add & at the beginning of each line to align the equations to the left. This does not require any additional packages or options, but it does require manually adding the & symbol at the beginning of each line.

Similar threads

Replies
1
Views
2K
Replies
3
Views
2K
Replies
5
Views
7K
Replies
2
Views
1K
Replies
6
Views
1K
Back
Top