0

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

Learnmore
  • 134
  • 6
  • your equation are to long that can be fit in text width, can be broken into more lines? – Zarko Apr 02 '19 at 05: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 02 '19 at 15:35

2 Answers2

2

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\\
&\quad+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*}
\end{document}

enter image description here

To avoid margin exceeding, consider adding \usepackage{geometry} or change the line-breaking points.

1

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)                                 \\
&\quad +(-3p^2q^2-p^2q-pq^2+6pq-3pq^2-pq-q^2+6q+9pq+3p+3q-18)   \\
&\quad +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*}
    \end{document}

enter image description here

Zarko
  • 296,517