3

I have a series of equations which I want to align at the equals sign. However I also wish for the left side of the last three lines to be left-aligned with each other (i.e. aligned to the widest of the three, not aligned flush to the left edge of the page).

Here's what I have currently:

Image of current output.

Here's what I'd like:

Image of desired output.

My code is as follows:

\begin{align*}
\text{Solve } D_1 = D_2 \Rightarrow \sqrt{(x-3)^2 + (y-4)^2} &= \sqrt{(y-2)^2}\\
(x-3)^2 + (y-4)^2 &= \quad (y-2)^2\\
(x^2 - 6x + 9) + (y^2 - 8y + 16) &= \quad y^2 - 4y + 4\\
x^2 - 6x + 21 &= \quad 4y\\
x^2 - 6x - 4y + 21 &= \quad 0
\end{align*}

It seems that what I'd like is an extra alignment point for the last 3 rows, but I haven't been able to find anything like that.

I've seen the aligned environment, but I believe that would break the alignment of the equals signs.

Any ideas?

4

With array environment:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[\setlength\arraycolsep{1pt}
\begin{array}{rll}
\text{Solve } D_1 
    & = D_2 \Rightarrow \sqrt{(x-3)^2 + (y-4)^2}    & = \sqrt{(y-2)^2}      \\
    &\hfill (x-3)^2 + (y-4)^2                       & = \quad (y-2)^2       \\
    & (x^2 - 6x + 9) + (y^2 - 8y + 16)              & = \quad y^2 - 4y + 4  \\
    & x^2 - 6x + 21                                 & = \quad 4y\\
    & x^2 - 6x - 4y + 21                            & = \quad 0
\end{array}
\]
\end{document}

enter image description here

5

The alignment seems very confusing but ...

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\newlength\zzz
\settowidth\zzz{$\displaystyle x^2 - 6x + 9) + (y^2 - 8y + 16)$}

\begin{align*}
\text{Solve } D_1 = D_2 \Rightarrow \sqrt{(x-3)^2 + (y-4)^2} &= \sqrt{(y-2)^2}\\
(x-3)^2 + (y-4)^2 &= \quad (y-2)^2\\
(x^2 - 6x + 9) + (y^2 - 8y + 16) &= \quad y^2 - 4y + 4\\
\makebox[\zzz][l]{$\displaystyle x^2 - 6x + 21$} &= \quad 4y\\
\makebox[\zzz][l]{$\displaystyle x^2 - 6x - 4y + 21$} &= \quad 0
\end{align*}



\end{document}
2
  • This looks like the most flexible solution, layout wise. Unfortunately the necessary commands aren't supported in my case (a third party website with MathJax). – Neil Haskins Jul 17 '20 at 16:46
  • @NeilHaskins ah well mathjax doesn't use tex so things are different in that case. – David Carlisle Jul 17 '20 at 18:18
2

I would suggest a slightly different way of computing, and another layout, with the \ArrowBetweenLinescommand from mathtools, which requires using alignat{2}:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{2}
\intertext{Solve $ D_1 = D_2 \Rightarrow $}
& & \sqrt{(x-3)^2 + (y-4)^2} &= \sqrt{(y-2)^2}\\
 \ArrowBetweenLines
& & (x-3)^2 + (y-4)^2 & = (y-2)^2\\
 \ArrowBetweenLines
 & & (x-3)^2 & = (y-2)^2 -(y-4)^2\\
  & & & = \bigl((y-2)-(y-4)\bigr)\bigl((y-2) + (y-4)\bigr)\\
 \ArrowBetweenLines
 & &x^2 - 6x + 9 & = 2 (2y -6)\\
 \ArrowBetweenLines
& & x^2 - 6x - 4y + 21 &= 0
\end{alignat*}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.