Math & ScienceBest Formatting for Equation Example

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Best Formatting for Equation Example

Post by tpa77l3 »

Hi guys,

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.
Screenshot 2020-04-12 at 05.25.19.png
Screenshot 2020-04-12 at 05.25.19.png (58.64 KiB) Viewed 8189 times
Many thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Best Formatting for Equation Example

Post by tpa77l3 »

This is the best that I've managed to come up with so far, but it does left justify the text:

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*}
Gives:
Screenshot 2020-04-13 at 04.52.01.png
Screenshot 2020-04-13 at 04.52.01.png (16.11 KiB) Viewed 8153 times
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Best Formatting for Equation Example

Post by Bartman »

Unfortunately, the example is incomplete again.

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}
tpa77l3
Posts: 19
Joined: Mon Feb 24, 2020 9:49 pm

Best Formatting for Equation Example

Post by tpa77l3 »

Sorry about the incomplete example again! Will remember for next time.

These are great thanks. Learning about alignnat and use of && has helped.
Post Reply