How to align several equations in latex

  • Context: LaTeX 
  • Thread starter Thread starter tabasco
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary

Discussion Overview

The discussion revolves around aligning multiple equations in LaTeX, particularly focusing on how to manage long equations that require alignment of both equal signs and corresponding terms. Participants explore various methods to achieve this alignment without relying on manual spacing adjustments.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks a way to align equations with corresponding terms and equal signs, expressing concern about the length of the equations.
  • Another participant suggests using an array environment for alignment, though they note that the equations appear to fit within one line.
  • A participant clarifies that their equations are more complex than presented and emphasizes the need to align specific terms without disrupting the overall structure.
  • One response proposes using \hspace for alignment but questions whether this approach is acceptable, highlighting the potential for manual adjustments if font sizes change.
  • Another participant suggests using phantom tags to maintain alignment while avoiding visible text, indicating a method to scale spacing appropriately.
  • A suggestion is made to use a matrix for alignment, although concerns are raised about how this might affect the clarity of the algebraic meaning.

Areas of Agreement / Disagreement

Participants express differing views on the best method for achieving the desired alignment, with no consensus reached on a single approach. Various techniques are proposed, each with its own advantages and drawbacks.

Contextual Notes

Participants mention specific formatting challenges, such as working in two-column mode and the complexity of the equations, which may affect alignment strategies. There are also concerns about the implications of using certain spacing techniques on the overall presentation.

tabasco
Messages
4
Reaction score
0
I'm trying to align several equations in latex. One of them is too long to fit in one line however, and I want to align that one in a way, where corresponding terms (in parentheses) are aligned - in addition to the alignment of the equal signs. This is what I want:

#######y1 = a*x + b*z
y2 = K*y1 = a*(x1 + x2) + b*(z1 + z2)
y3 = K*y2 = a*(x1 + x2) + b*(c*(z1 + z2)
#############################+ d*(z1 – z2))



The ### are placeholders so I could get the alignment right in this post.


Is there any way of doing this properly? Without \quad and the likes... ?
By inserting additional alignment tags only in the last equation?



- T
 
Last edited:
Physics news on Phys.org
tabasco said:
Is there any way of doing this properly?
Like this?

[tex] \begin{array}{rrrcll}<br /> &&y1&=&a*x + b*z&\\<br /> y2&=&K*y1&=&a*(x1 + x2)&+\ b*(z1 + z2)\\<br /> y3&=&K*y2&=&a*(x1 + x2)&+\ b*(c*(z1 + z2)\\<br /> &&&&&+\ d*(z1 – z2))<br /> \end{array}[/tex]

It doesn't look like it's too long to go on one line, but whatever. :smile:

- Warren
 
Chroot, thanks for the quick reply
but it doesn't quite solve my problem: The variables I put down in the post are really more complex terms. So the first line is already way longer than what it looks like in the post and am using the twocolumn-mode for an article.

So there are two points I want aligned: First, for all three equations, the row of three equal-signs, just how it is in your reply. That's simple...

Second, the "+" in line three with the "c" in line 4. The hard part is doing that without ripping the above lines apart. There is no corresponding alignment point in the first two lines.
Since the first line is really longer than what I put down here I don't know where to put an extra "&"...

Phew, I hope you understand that explanation... :confused:

- T
 
[tex]\begin{align*}<br /> y1&=a*x + b*z\\<br /> y2=K*y1&=a*(x1 + x2)+\ b*(z1 + z2)\\<br /> y3=K*y2&=a*(x1 + x2)+\ b*(c*(z1 + z2)\\<br /> &&\hspace*{-26ex}+\ d*(z1 – z2))<br /> \end{align*}[/tex]

Is using \hspace cheating? (Note the extra & in the last line.)
 
I guess I could do it like that... but yes, I think that would be cheating. The hspace needed is trial and error, and when I change the fontsize I'd have to change the spacing manually, right.

Maybe there's a way of inserting "invisible" text? If I could insert everything from the upper line up until the point I want aligned without displaying it, that would work... Any ideas?

- T
 
By specifying the dimensions in units of ex, I would think that the spacing would scale reasonably well.

[tex]\begin{align*}<br /> y1&=a*x + b*z\\<br /> y2=K*y1&=a*(x1 + x2)+\ b*(z1 + z2)\\<br /> y3=K*y2&=a*(x1 + x2)+\ b*(c*(z1 + z2)\\<br /> &\hphantom{=a*(x1 + x2)+\ b*(}+\ d*(z1 – z2))<br /> \end{align*}[/tex]

You can use the phantom (\[hv]phantom) tags.
 
Try using a matrix.

JMD
 
[tex]\begin{align*}<br /> y1&=a*x + b*z\\<br /> y2=K*y1&=a*(x1 + x2)+\ b*(z1 + z2)\\<br /> y3=K*y2&=a*(x1 + x2)+<br /> \begin{array}[t]{ll}<br /> b*(&\!\!\! c*(z1 + z2)\\ <br /> &\!\!\! +\ d*(z1 – z2))<br /> \end{array}<br /> \end{align*}[/tex]

This is a little cleaner... but it messes up the algebraic meaning.
 
I am actually working on useing latex on my own forum ... hopefully it will work well
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
17
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 5 ·
Replies
5
Views
4K