TransWikia.com

Left-align math and also align by equal sign?

TeX - LaTeX Asked on December 17, 2020

begin{flalign*}
    &f(x) = -1.25x^{2} + 1.5x + 1.66&
         &= -1.25x^{2} + 1.5x + 1.66 + 0&
end{flalign*}

Is it possible to left-align these two lines of math and also align the two lines by the equal signs?

enter image description here

2 Answers

To align at the =, you need to have the & to be just before the =:

enter image description here

##Code:

documentclass{article}
usepackage{mathtools}
usepackage{showframe}

begin{document}
begin{flalign*}
    f(x) &= -1.25x^{2} + 1.5x + 1.66     & 
         &= -1.25x^{2} + 1.5x + 1.66 + 0 & 
end{flalign*}
end{document}

Correct answer by Peter Grill on December 17, 2020

The fl in flalign and flalign* is short for "full length", not "flush left". Please see page 8 of the user guide of the amsmath package for some use cases for flalign. (Aside: Just because flalign can be abused to force displayed equations to be typeset left-aligned doesn't mean that it's harmless to do so.)

If the objective is to typeset displayed equations left-aligned rather than centered, you really shouldn't be using flalign. Instead, load the amsmath or mathtools package with the option fleqn (short for "flush-left equations") and set the value of the mathindent length variable to 0pt.

enter image description here

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

begin{document}
begin{align*}
    f(x) &= -1.25x^{2} + 1.5x + 1.66 
         &= -1.25x^{2} + 1.5x + 1.66 + 0 % note: no '' at end of final line of 'align'
end{align*}
end{document}

Answered by Mico on December 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP