Math & ScienceAlign Equations within Align?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Align Equations within Align?

Post by SaneAssasin »

Hi,

In this minimal working example, I want to align these I(\theta) and Var(\hat{\theta}), but can't seem to figure it out.

Any suggestions on how this can be done?

Code: Select all

\documentclass{Article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
I(\theta)&=\frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}
\\&=\frac{2n}{\theta(1-\theta)}
\end{align*}
\[Var(\hat{\theta})\approx\frac{1}{I(\theta})\indent I(\hat{\theta}=\frac{2n}{\hat{\theta}(1-\hat{\theta})}\]
\end{document} 
Thanks!

Recommended reading 2024:

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

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

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Align Equations within Align?

Post by svend_tveskaeg »

First: This is not a MWE. If you had tried to compiled it yourself before posting it, you would see that.

Here is a MWE (assuming that I have understood you correct):

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\var}{Var}

\begin{document}

\begin{align*}
  I(\theta)
  &= \frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}
   = \frac{2n}{\theta(1-\theta)}\\
  \var(\hat{\theta})
  &\approx \frac{1}{I(\theta)}\\
  I(\hat{\theta})
  &= \frac{2n}{\hat{\theta}(1-\hat{\theta})}
\end{align*}

\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Align Equations within Align?

Post by SaneAssasin »

svend_tveskaeg wrote:First: This is not a MWE. If you had tried to compiled it yourself before posting it, you would see that.

Here is a MWE (assuming that I have understood you correct):

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\var}{Var}

\begin{document}

\begin{align*}
  I(\theta)
  &= \frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}
   = \frac{2n}{\theta(1-\theta)}\\
  \var(\hat{\theta})
  &\approx \frac{1}{I(\theta)}\\
  I(\hat{\theta})
  &= \frac{2n}{\hat{\theta}(1-\hat{\theta})}
\end{align*}

\end{document}
How was what I posted not a minimum working example? I did compile it before I posted it and it didn't give any errors, and I haven't used any obscure packages.

But anyway, I want the to break the first line at the second equal sign and align it with the first equal sign, as I had in the example I gave:

Code: Select all

 \begin{align*}
I(\theta)&=\frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}
\\&=\frac{2n}{\theta(1-\theta)}
\end{align*}

I then want to align

Code: Select all

 Var(\hat{\theta})\approx\frac{1}{I(\theta})\indent I(\hat{\theta}=\frac{2n}{\hat{\theta}(1-\hat{\theta})} 
with I(\theta) of the first equation.

Does that make sense? And also, please tell me how that's not a proper MWE...A lot of people have said that in my posts, but I don't understand how...
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Align Equations within Align?

Post by svend_tveskaeg »

It is not a minimal working example because your code can't be compiled. The name of the document class is article, not Article. (And I am absolutely positive that you haven't compiled it, because it can't be done.)

Now to your example: Maybe this is what you want (even though I think my suggestion looks better but that is of course for you to decide):

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\var}{Var}

\begin{document}

\begin{align*}
  I(\theta)
  &= \frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}\\
  &= \frac{2n}{\theta(1-\theta)}\\
  \var(\hat{\theta})
  &\approx \frac{1}{I(\theta)}
  \qquad I(\hat{\theta}) = \frac{2n}{\hat{\theta}(1-\hat{\theta})}
\end{align*}

\end{document}
Last edited by svend_tveskaeg on Wed Feb 20, 2013 5:43 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Align Equations within Align?

Post by SaneAssasin »

svend_tveskaeg wrote:It is not a minimal working example because your code can't be compiles. The name of the document class is article, not Article. (And I am absolutely positive that you haven't compiled it, because it can't be done.)

Now to your example: Maybe this is what you want (even though I think my suggestion looks better but that is of course for you to decide):

Code: Select all

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\var}{Var}

\begin{document}

\begin{align*}
  I(\theta)
  &= \frac{2n(1-\theta)^2+2n(\theta(1-\theta)}{(1-\theta)^2}+\frac{2n\theta(1-\theta)+2n\theta^2}{\theta^2}\\
  &= \frac{2n}{\theta(1-\theta)}\\
  \var(\hat{\theta})
  &\approx \frac{1}{I(\theta)}
  \qquad I(\hat{\theta}) = \frac{2n}{\hat{\theta}(1-\hat{\theta})}
\end{align*}

\end{document}

Hi,

Yes, this is what I was trying to do, thanks!

And no, I definitely compiled it using PDFLaTeXify, WinEdt 7.0 and Miktek 2.9.

Any idea why I can and you can't...? :S
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Re: Align Equations within Align?

Post by SaneAssasin »

Actually, I tried writing it all in capitals and it still compiles. I don't think document classes are case sensitive...
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Align Equations within Align?

Post by svend_tveskaeg »

SaneAssasin wrote:Actually, I tried writing it all in capitals and it still compiles. I don't think document classes are case sensitive...
Well, it is because of what I said, that is all I can say.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Align Equations within Align?

Post by SaneAssasin »

svend_tveskaeg wrote:
SaneAssasin wrote:Actually, I tried writing it all in capitals and it still compiles. I don't think document classes are case sensitive...
Well, it is because of what I said, that is all I can say.

Okay, well, it compiled perfectly as is. Anyway, thanks. :)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Align Equations within Align?

Post by svend_tveskaeg »

Try to compile your code by clicking on the "OPEN IN WRITELATEX" botton. Next, change Article to article and try again.
Last edited by svend_tveskaeg on Tue Feb 19, 2013 7:51 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
SaneAssasin
Posts: 14
Joined: Thu Feb 07, 2013 1:02 am

Align Equations within Align?

Post by SaneAssasin »

svend_tveskaeg wrote:Try to compile your code by clicking on the "OPEN IN WRITELATEX" Botton. Next, change Article to article and try again.
Okay, my apologies. It compiled perfectly in my editor, which is what I was trying to say.

Sorry if I came off rude. :)
Post Reply