38

The following is a small example to use flalign environment to generate equation.

\documentclass{article}
\usepackage{amsmath}
\usepackage{txfonts}

\begin{document}
The formula is:
\begin{flalign*}
  \lambdaup &= \lambdaup_1 + \lambdaup_2\\
\end{flalign*}

\end{document}

The output aligns at the center:

The formula is
                  lambda = lambda_1 + lambda_2

How can I make the alignment to the left, using flalign, alignat or align environment? I mean:

The formula is
lambda = lambda_1 + lambda_2

According to Michael's comment, adding option [fleqn] to package amsmath and setting \mathindent=0.0pt will solve the problem. But this will make all equations align to the left. How can I make the function locally to some environment instead of the whole article?

2
  • 3
    Displayed equations are usually centered. You can pass the option fleqn to either the document class or to amsmath to get displayed equations that are aligned to the left. However, they are still indented slightly unless you change the value of mathindent. Commented Mar 23, 2011 at 8:27
  • @Michael: Yes, mathindent is a point.
    – warem
    Commented Mar 23, 2011 at 9:13

3 Answers 3

35

You can use Flalign instead.

The formula is
\begin{flalign*}
a &= b+c &\\
  &= 1+1 &\\
  &= 2  &
\end{flalign*}
4
  • 4
    I just found that if the content in flalign has math, it doesn't work. Please have a look at the updated example.
    – warem
    Commented Mar 23, 2011 at 9:01
  • 16
    You need to add & after each line, i.e. write \lambdaup &= \lambdaup_1 + \lambdaup_2 &. Commented Mar 23, 2011 at 10:17
  • 2
    @Michael: yes, adding & at the end of line does work. Thank you.
    – warem
    Commented Mar 23, 2011 at 14:21
  • 1
    @MichaelUmmels why we need to add & at the end? Commented Mar 1 at 17:17
25

Using the flalign environment (numbered equations) or the flalign* (unnumbered equations) environment, left alignment can be obtained with two ampersands (&). If the only alignment you want is for the equations to be left-aligned, put an ampersand at the beginning and end of each line, like so:

\begin{flalign*}
  & \lambda = \lambda_1 + \lambda_2 &\\
  & \Lambda = \Lambda_1 + \Lambda_2 &
\end{flalign*}

If you want to have left-alignment but also align by some character (say, the = sign), put the first ampersand immediately before the character you want to align by, and the second ampersand at the end of each line, like so:

\begin{flalign*}
  \lambda &= \lambda_1 + \lambda_2 &\\
          &= \Lambda &\\
          &= \Lambda_1 + \Lambda_2 &
\end{flalign*}

Credit to Lauer, whose answer I used to help me figure out the same issue, then expanded upon.

2
  • 1
    This, did it for me. I tried so many other solutions, but they did not work. The ampersands at the beginning and the end are crucial. Commented Dec 9, 2016 at 3:19
  • Why we need the ampersand at the end? Commented Aug 13 at 1:48
6

The trick is to give amsmath the parameter fleqn:

\usepackage[fleqn]{amsmath}

Edit: This produces a slightly different output than flalign*.

1
  • @Michael: Now I know the option fleqn. Thank you. I think this option will work for all equations in article. This is its advantage and disadvantage since not all equations will be displayed to the left. So it is better to set right environment at where you want, just like what Lauer does.
    – warem
    Commented Mar 23, 2011 at 8:43

Not the answer you're looking for? Browse other questions tagged .