How to align several equations in latex

  • LaTeX
  • Thread starter tabasco
  • Start date
  • Tags
    Latex
In summary: Forum/viewtopic.php?f=22&t=16In summary, the conversation discusses how to properly align equations in LaTeX, specifically when one equation is too long to fit on one line. The solution involves using alignment tags and possibly inserting "invisible" text or using a matrix. However, some methods may be considered "cheating" or may affect the algebraic meaning. The conversation also references the use of LaTeX on a forum and provides a link for further discussion.
  • #1
tabasco
4
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
  • #2
tabasco said:
Is there any way of doing this properly?
Like this?

[tex]
\begin{array}{rrrcll}
&&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))
\end{array}
[/tex]

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

- Warren
 
  • #3
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
 
  • #4
[tex]\begin{align*}
y1&=a*x + b*z\\
y2=K*y1&=a*(x1 + x2)+\ b*(z1 + z2)\\
y3=K*y2&=a*(x1 + x2)+\ b*(c*(z1 + z2)\\
&&\hspace*{-26ex}+\ d*(z1 – z2))
\end{align*}[/tex]

Is using \hspace cheating? (Note the extra & in the last line.)
 
  • #5
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
 
  • #6
By specifying the dimensions in units of ex, I would think that the spacing would scale reasonably well.

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

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

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

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

1. What is LaTeX?

LaTeX is a typesetting system used for creating high-quality documents, particularly in the fields of mathematics, science, and engineering. It allows for precise control over formatting and is often used for academic publications and technical documentation.

2. What is aligning in LaTeX?

Aligning in LaTeX refers to the process of organizing equations or text into a specific alignment, typically for mathematical expressions. This can be done using the \begin{align} and \end{align} commands or the \align* environment.

3. How do I align equations in LaTeX?

To align equations in LaTeX, you can use the align environment and use the & symbol to indicate where you want the alignment to occur. You can also use the align* environment to align equations without numbering them.

4. Can I align text and equations in LaTeX?

Yes, you can align both text and equations in LaTeX by using the align environment. You can also use the flalign environment for specific types of alignment, such as aligning equations at the left and right margins.

5. How do I adjust the spacing between aligned equations in LaTeX?

You can adjust the spacing between aligned equations in LaTeX by adding the \hspace and \vspace commands within the align environment. These commands allow you to adjust the horizontal and vertical spacing between equations, respectively.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
2K
  • Precalculus Mathematics Homework Help
Replies
17
Views
990
  • General Math
Replies
3
Views
879
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • Linear and Abstract Algebra
Replies
17
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
275
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Replies
2
Views
2K
  • Programming and Computer Science
Replies
5
Views
5K
Back
Top