Math & Science ⇒ Best Formatting for Equation Example
Best Formatting for Equation Example
Newbite queestion; what would be the best way to display the following? I'm after the alignment bewteen the wording and the equations to be the same as shown along with the vertical alignment between the new lines.
Many thanks.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Best Formatting for Equation Example
Code: Select all
\begin{align*}\text{The equation is:}\hspace{10mm}&9a-4=14+3a\\\text{Subtract $3a$:}\hspace{10mm}&6a-4=14\\\text{Subtract 4:}\hspace{10mm}&6a=18\\\text{Divide by 6:}\hspace{10mm}&a=3\end{align*}
Best Formatting for Equation Example
I chose the
alignat
environment because I could not reduce the horizontal distance in the align
environment. Manually increasing the distance in the alignat
environment may be trickery, but it works.It could also be implemented with a
tabular
or array
environment, but then the line spacing would have to be increased.Code: Select all
\documentclass{article}\usepackage{mathtools}% loads amsmath\begin{document}\begin{align*}&\text{The equation is:} && 9a-4 = 14+3a\\&\text{Subtract $3a$:} && 6a-4=14\\&\text{Subtract 4:} && 6a=18\\&\text{Divide by 6:} && a=3\end{align*}\begin{alignat*}{2}&\text{The equation is:}\qquad && 9a-4 = 14+3a\\&\text{Subtract $3a$:} && 6a-4=14\\&\text{Subtract 4:} && 6a=18\\&\text{Divide by 6:} && a=3\end{alignat*}% I prefer the alignment at the equal sign.\begin{alignat*}{2}&\text{The equation is:}\qquad & 9a-4 &= 14+3a\\&\text{Subtract $3a$:} & 6a-4 &= 14\\&\text{Subtract 4:} & 6a &= 18\\&\text{Divide by 6:} & a &= 3\end{alignat*}\end{document}
Best Formatting for Equation Example
These are great thanks. Learning about
alignnat
and use of &&
has helped.