# How to align the lines on the left

Consider the code

\begin{align*}

(pq+q-3)^2-(3pq+p+q-6)(pq+q-3)+2(p^2q^2+p^2q+pq^2-7pq+p+q+2)\\
=&\;(p^2q^2+q^2+9+2pq^2-6q-6pq)

+(-3p^2q^2-p^2q-pq^2+6pq-3pq^2-pq-q^2+6q+9pq+3p+3q-18)\\+2(p^2q^2+p^2q+pq^2-7pq+p+q+2)\\

=&\;p^2q-5-6pq+5p+5q\\

=&\;pq(p-6)+5(p+q-1)\\
\end{align*}


I used the technique which was shown here How to align the equations to start from left

but I it is not working here.

The lines are getting disbalanced.Can someone help please

• your equation are to long that can be fit in text width, can be broken into more lines? – Zarko Apr 2 at 5:11
• align is designed to provide the correct spacing after operators when the & is placed before them. Moving the & would get rid of the need to explicitly add space. – barbara beeton Apr 2 at 15:35

First of all: remove all blank lines inside align*.

Some of your lines don't have &, which causes the equation to be unbalanced.

Fix:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
&\;(pq+q-3)^2-(3pq+p+q-6)(pq+q-3)+2(p^2q^2+p^2q+pq^2-7pq+p+q+2)\\ =&\;(p^2q^2+q^2+9+2pq^2-6q-6pq)+(-3p^2q^2-p^2q-pq^2+6pq-3pq^2-pq-q^2+6q\\
=&\;p^2q-5-6pq+5p+5q\\
=&\;pq(p-6)+5(p+q-1)\\
\end{align*}
\end{document} To avoid margin exceeding, consider adding \usepackage{geometry} or change the line-breaking points.

• Yes,how does the package geometry help and how to use it,if i use it will it automatically align the lines to the left – Learnmore Apr 2 at 5:20
• @Learnmore article's default margin is very big and IMHO ugly, and geometry can make the margin much nicer. You can even control the margin using this package. For more information read the package documentation. – user156344 Apr 2 at 5:23
• How should i use it,will writing \usepackage{geometry} take care of all4 – Learnmore Apr 2 at 5:31
• @Learnmore It only takes care of the margin. You can set your own margin by \usepackage[margin=1in]{geometry} or \usepackage[top=1cm,bottom=2cm,left=3cm]{geometry}, etc. – user156344 Apr 2 at 5:36

with use of the macro \MoveEqLeft from the package mathtools and correct placing of ampersands:

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\begin{align*}
\MoveEqLeft
(pq+q-3)^2-(3pq+p+q-6)(pq+q-3)+2(p^2q^2+p^2q+pq^2-7pq+p+q+2)    \\
& = (p^2q^2+q^2+9+2pq^2-6q-6pq)                                 \\ 