How to left align the \align environment

  • Context: MHB 
  • Thread starter Thread starter rapid1
  • Start date Start date
Click For Summary
SUMMARY

The forum discussion addresses how to left-align the \align environment in LaTeX documents. The user initially presents a centered \align* environment and seeks a method to left-align it without affecting all \align instances. A solution is provided using the aligned environment within a custom command \leftdisplay, which allows for precise placement of the aligned equations. The discussion also references Knuth's The TeXbook for further reading.

PREREQUISITES
  • Familiarity with LaTeX typesetting
  • Understanding of the \align and aligned environments
  • Knowledge of custom command definitions in LaTeX
  • Basic concepts of horizontal and vertical boxes in LaTeX
NEXT STEPS
  • Research the use of the aligned environment in LaTeX
  • Learn how to create custom commands in LaTeX
  • Explore the differences between hbox and vbox in LaTeX
  • Read Knuth's The TeXbook for advanced typesetting techniques
USEFUL FOR

LaTeX users, mathematicians, and anyone involved in typesetting documents that require specific alignment of mathematical equations.

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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K