LaTeX forum ⇒ Math & ScienceBest Formatting for Equation Example Topic is solved

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

Best Formatting for Equation Example

Postby tpa77l3 » Sun Apr 12, 2020 6:30 am

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 591 times


Many thanks.

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

Postby tpa77l3 » Mon Apr 13, 2020 5:52 am

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

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \begin{align*}
  2. \text{The equation is:}\hspace{10mm}&9a-4=14+3a\\
  3. \text{Subtract $3a$:}\hspace{10mm}&6a-4=14\\
  4. \text{Subtract 4:}\hspace{10mm}&6a=18\\
  5. \text{Divide by 6:}\hspace{10mm}&a=3
  6. \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 555 times

Bartman
Posts: 97
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Mon Apr 13, 2020 7:32 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass{article}
  2. \usepackage{mathtools}% loads amsmath
  3.  
  4. \begin{document}
  5. \begin{align*}
  6. &\text{The equation is:} && 9a-4 = 14+3a\\
  7. &\text{Subtract $3a$:} && 6a-4=14\\
  8. &\text{Subtract 4:} && 6a=18\\
  9. &\text{Divide by 6:} && a=3
  10. \end{align*}
  11.  
  12. \begin{alignat*}{2}
  13. &\text{The equation is:}\qquad && 9a-4 = 14+3a\\
  14. &\text{Subtract $3a$:} && 6a-4=14\\
  15. &\text{Subtract 4:} && 6a=18\\
  16. &\text{Divide by 6:} && a=3
  17. \end{alignat*}
  18.  
  19. % I prefer the alignment at the equal sign.
  20. \begin{alignat*}{2}
  21. &\text{The equation is:}\qquad & 9a-4 &= 14+3a\\
  22. &\text{Subtract $3a$:} & 6a-4 &= 14\\
  23. &\text{Subtract 4:} & 6a &= 18\\
  24. &\text{Divide by 6:} & a &= 3
  25. \end{alignat*}
  26. \end{document}

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

Postby tpa77l3 » Wed Apr 15, 2020 5:23 am

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

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


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 0 guests