LaTeX forum ⇒ GeneralAligning a system of linear equations

LaTeX specific issues not fitting into one of the other forums of this category.
Plato
Posts: 6
Joined: Wed Nov 19, 2014 7:08 pm

Aligning a system of linear equations

Postby Plato » Sat Jan 03, 2015 1:21 am

  1. \documentclass[11pt,a4paper,openany]{report}
  2. \usepackage{amssymb,amsmath,amsthm}
  3. \usepackage[dutch]{babel}
  4. \usepackage{mdframed}
  5. \usepackage{systeme,mathtools}
  6. \usepackage{lipsum}
  7. \usepackage{relsize}
  8. \newcommand\md{\ }
  9. \renewcommand{\qedsymbol}{$\blacksquare$}
  10. \begin{document}
  11.  
  12. \systeme{x_1=2r + s -t,x_2= r, x_3=-2s +2t, x_4=s, x_5=t}

Hello, I want to align a system of equations such that the x_1, x_2, x_3, x_4, x_5 are all underneath each other. Right now I get my system in staircase-form, like:
x_1 = 2r + s - 3t
......x_2 = r
...........x_3 = -2s + 2t
(there is empty space where the dots are) etc. I want all the x_i's aligned nicely under each other. Can someone help me with this? Thank you in advance.

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 3763
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Jan 05, 2015 9:45 am

That is the expected behaviour of the package, try the cases-environment instead.
  1. \documentclass[11pt,a4paper,openany]{report}
  2. \usepackage{amssymb,amsmath,amsthm}
  3. \usepackage[dutch]{babel}
  4. \usepackage{mdframed}
  5. \usepackage{systeme,mathtools}
  6. \usepackage{lipsum}
  7. \usepackage{relsize}
  8. \newcommand\md{\ }
  9. \renewcommand{\qedsymbol}{$\blacksquare$}
  10. \begin{document}
  11.  
  12. \systeme{x_1=2r + s -t,x_2= r, x_3=-2s +2t, x_4=s, x_5=t}
  13. \[\begin{cases}x_1=2r + s -t\\x_2= r\\ x_3=-2s +2t\\ x_4=s\\ x_5=t
  14. \end{cases}
  15. \]
  16. \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 8905
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Jan 05, 2015 2:10 pm

To add to what Johannes, said, that package is for aligning terms and signs vertically, such that there's a column for each variable. That's especially good if you got several variables in each row. However, it may look a bit strange in the case of a single variable in each row when all are different. That's the case above.

As Johannes wrote, cases fits better here and is easy to write. In the current situation the terms at the left have roughly the same width. But if you got different widths, it could be good to use additional alignment. Here I change x_5 to x_{10} just as a demonstration. I used the aligned environment instead.

  1. \documentclass[11pt,a4paper,openany]{report}
  2. \usepackage{amssymb,amsmath,amsthm}
  3. \usepackage[dutch]{babel}
  4. \usepackage{mdframed}
  5. \usepackage{systeme,mathtools}
  6. \usepackage{lipsum}
  7. \usepackage{relsize}
  8. \newcommand\md{\ }
  9. \renewcommand{\qedsymbol}{$\blacksquare$}
  10. \begin{document}
  11. \systeme{x_1=2r + s -t,x_2= r, x_3=-2s +2t, x_4=s, x_10=t}
  12. \[\begin{cases}x_1=2r + s -t\\x_2= r\\ x_3=-2s +2t\\ x_4=s\\ x_{10}=t
  13. \end{cases}
  14. \]
  15. \[
  16. \left\{\begin{aligned}
  17. x_1 &= 2r + s -t \\
  18. x_2 &= r \\
  19. x_3 &= -2s + 2t \\
  20. x_4 &= s \\
  21. x_{10} &= t
  22. \end{aligned}\right.
  23. \]
  24. \end{document}


Stefan
Site admin


Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests