Math & Sciencealign problem

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

align problem

Post by bkarpuz »

Hi friends,

I sue the following code

Code: Select all

\documentclass[12pt]{article}

\usepackage{amsmath}

\begin{document}
\begin{align}
\int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta=&\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
=&-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
&\begin{aligned}
&=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
&+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg).
\end{aligned}\label{lbleq1}
\end{align}
\end{document}
but I want the = signs to be one under the other, how can I do it?

thanks.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

align problem

Post by localghost »

First of all you make false use of the alignment character ("&"). Always insert it before the equal sign. The second issue is that the additional aligned environment is not necessary.

Code: Select all

\begin{align}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg) \label{lbleq1}
\end{align}

Best regards
Thorsten¹
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

Re: align problem

Post by bkarpuz »

thanks for your reply, but I need equation number to be placed in the middle of the last two equation lines.

is that possible?

thanks again.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

align problem

Post by gmedina »

bkarpuz wrote:...I need equation number to be placed in the middle of the last two equation lines.

is that possible?
I don't know if I understood your petition correctly. If you want to adjust the vertical position of the tags you can use the \raisetag command provided by the amsmath package; however, this command will only have effect if the tag has been previously shifted from its normal position. For this reason, in the code below I used an invisible rule to force the tags to be moved and then I used \raisetag to correct their position:

Code: Select all

\documentclass{book}
\usepackage{amsmath}

\begin{document}

\begin{align}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi \rule{3cm}{0pt}\raisetag{35pt}\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg) \rule{3cm}{0pt}\raisetag{35pt}\label{lbleq1}
\end{align}

\end{document}
Of course, instead of 35pt you can use the value that suits your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

align problem

Post by bkarpuz »

gmedina wrote:
bkarpuz wrote:...I need equation number to be placed in the middle of the last two equation lines.

is that possible?
I don't know if I understood your petition correctly. If you want to adjust the vertical position of the tags you can use the \raisetag command provided by the amsmath package; however, this command will only have effect if the tag has been previously shifted from its normal position. For this reason, in the code below I used an invisible rule to force the tags to be moved and then I used \raisetag to correct their position:

Code: Select all

\documentclass{book}
\usepackage{amsmath}

\begin{document}

\begin{align}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi \rule{3cm}{0pt}\raisetag{35pt}\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg) \rule{3cm}{0pt}\raisetag{35pt}\label{lbleq1}
\end{align}

\end{document}
Of course, instead of 35pt you can use the value that suits your needs.
Thanks vm, that's what I am looking for.
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

align problem

Post by phi »

bkarpuz wrote:thanks for your reply, but I need equation number to be placed in the middle of the last two equation lines.
Use a split environment:

Code: Select all

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
  \begin{split}
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg)
  \end{split} \label{lbleq1}
\end{align}

\end{document}
In general, use align for multiple equations and split for single equations that span more than one line. As you can see, the numbering is different.
Manual adjustments are unnecessary in this case.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

align problem

Post by gmedina »

phi wrote:
bkarpuz wrote:thanks for your reply, but I need equation number to be placed in the middle of the last two equation lines.
Use a split environment:

Code: Select all

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\notag\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\notag\\
  \begin{split}
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg)
  \end{split} \label{lbleq1}
\end{align}

\end{document}
In general, use align for multiple equations and split for single equations that span more than one line. As you can see, the numbering is different.
Manual adjustments are unnecessary in this case.
As I understood, the OP's petition involved two tags. The split environment will produce only one tag. That's the reason that led me to design my solution using a manual adjustment instead of split.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

align problem

Post by phi »

gmedina wrote:As I understood, the OP's petition involved two tags.
I don't think so.
I need equation number to be placed in the middle of the last two equation lines.
So he wants one equation number in the middle of the last two lines. That is exactly what his original code does, and there he only complains about the equal signs, which can be corrected by using a split environment. Placing the tag between these lines is sensible because they contain a split expression, but placing another tag somewhere else wouldn't make much sense.
Personally I think that every equation should have at most one vertically centered number, like this:

Code: Select all

\begin{equation}
  \begin{split}
  \int_{t}^{\infty}\frac{(\eta-t)^{n}}{n!}f(\eta)d\eta&=\int_{t}^{\infty}\int_{\eta}^{t}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\xi d\eta\\
  &=-\int_{t}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
  &=-\bigg(\int_{s}^{\infty}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\\
  &\hphantom{=}\;\,+\int_{t}^{s}\int_{\xi}^{\infty}\frac{(\xi-\eta)^{n-1}}{(n-1)!}f(\eta)d\eta d\xi\bigg)
  \end{split} \label{lbleq1}
\end{equation}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

align problem

Post by gmedina »

phi wrote:
gmedina wrote:As I understood, the OP's petition involved two tags.
I don't think so.
Well, I thought so, and that's why I took the time to give my solution; had I thought differently then, of course I, would have suggested the use of a split environment.
phi wrote:...but placing another tag somewhere else wouldn't make much sense.
As to what makes sense or not, let me tell you that after seeing some really bizarre requirements I don't know anymore what makes sense and what doesn't.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

align problem

Post by bkarpuz »

phi and gmedina thanks for the solutions split looks easier.

ty vm.
Post Reply