22

How can I left align the display math environment (either $$ or \[)? I keep running into people asking about the align environment; but I just want to change displayed math from center to left align relative to the page.

lockstep
  • 250,273
knpwrs
  • 1,485
  • 1
    I saw that style in a book and like it, since I did not have to look all over the page width for the formulas, but found them on the left side as well. Is there something I should keep in mind, when I use this style? – Martin Ueding Oct 23 '12 at 13:13

2 Answers2

25

You can use flalign from the amsmath package:

enter image description here

Note:

  • The showframe package was used just to be able to see where the text is relative to the page margins.

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
e & = mc ^2 &\\%  Note the trailing & which is required to equations to the left
F & = ma
\end{flalign*}
\end{document}

Alternatively, if you want all equations left aligned, you can use the package option fleqn as in \documentclass[fleqn]{article} which will align them towards the left. The indentation is controlled by \mathindent, so you could use \setlength{\mathindent}{0pt} if you wanted to eliminate that.

Code:

\documentclass[fleqn]{article}
\usepackage{showframe}
\usepackage{amsmath}
\setlength{\mathindent}{0pt}

\begin{document} \begin{align} e & = mc ^2 \ F & = ma \end{align} \end{document}

Peter Grill
  • 223,288
  • 7
    I don't get it - that's exactly what OP said he wants to avoid in question: I keep running into people asking about the align environment; but I just want to change displayed math from center to left align relative to the page. I think he means to align all displaymath (using $$) left. I know this thread is old, but that's what I was looking for when entered this page through google. – trakos Feb 09 '14 at 22:53
  • @trakos: I am not sure what you mean. The OP wanted to "left align the display math environment", which is what this answer does. I suggest you post a new question detailing what you want, and you can reference this question if it is relevant. Please do include a MWE including \documentclass and the appropriate packages that sets up the problem. – Peter Grill Feb 09 '14 at 23:00
  • 1
    for some reason the first solution in this answer doesn't do the trick for me. – dKab Feb 26 '19 at 21:53
  • Perhaps you should note in your answer the importance of & in first case. I had to wrap my formula in ampersands for this to work. You do have a comment about trailing & but you don't mention that it's required to have & before the expression as well. – dKab Feb 26 '19 at 22:07
  • @dKab: The first & is needed to get the = to align. If this question gets edited in the future I will add that note. – Peter Grill Feb 27 '19 at 09:02
5

It seems that the current accepted answer doesn't exactly answer the question (OP stated either $$ or \[ and not the align environment because he already found a solution for that).

Here is a solution with \[ ... \] (doesn't work with $$...$$ though):

\documentclass[fleqn]{article}
\setlength{\mathindent}{0pt}
\begin{document}
\noindent Here is some left-aligned math:
\[x^2+1\]
\end{document}

enter image description here

Basj
  • 764
  • 5
    I believe \setlength{\mathindent}{0pt} is sticky (it will affect the entire remainder of the document, unless you later reset it. I am not even sure that you can use \setlength{\mathindent} mid document to reset it. Is there someway to left-align a single block of displaymath without affecting any of the other blocks of displaymath? One equation becomes left-aligned; all others are centered? – IdleCustard Jan 09 '19 at 16:04