5

I have the following system of equations in Texmaker:

\begin{equation}
\begin{align}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} = 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\end{align}
\label{system}
\end{equation}

When I compile, the following error message is given:"Package amsmath error: Erroneous nesting of equation structures; (amsmath) trying to recover with aligned...." However, I can still produce a normal looking PDF file.

I'd be very grateful if someone could point out how to correct this error. I have the amsmath package installed.

  • 1
    align is already in math mode, so get rid of the equation environment. – Steven B. Segletes May 30 '17 at 12:25
6

You should not nest align in equation. The align environment is enough:

\documentclass[]{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} = 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\label{system}
\end{align}
\end{document}

This compiles (but looks terrible, imho).

With horizontal alignment it looks better I think:

\documentclass[]{article}

\usepackage{amsmath}
\usepackage[margin=1cm]{geometry}

\begin{document}
Without alignment:
\begin{align}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} = 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\label{system}
\end{align}

With alignment:
\begin{align}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} &= a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) &= b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} &= 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} &= \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} &= \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\label{system2}
\end{align}
\end{document}

enter image description here

  • Thanks! By the way, what would you do to make it look less "terrrible"? @Skillmon – Alex May 30 '17 at 12:31
  • @Alex I would add a & to all the = in the split-environment. This way, the = get horizontally aligned, which makes the appearance clearer, imho. – Skillmon May 30 '17 at 12:32
  • What's the usefulness of split nested in align? – Bernard May 30 '17 at 12:56
  • @Bernard the placement of the equation number in the vertical center. If it's wanted, I think split is really handy (and I just didn't remove it from the question) – Skillmon May 30 '17 at 13:08
  • @Skillmon: Oh! yes. Usually I do that with equation+aligned (or +split), so it seemed strange to me. – Bernard May 30 '17 at 13:38
3

align already puts you in math mode, so get rid of the redundant equation environment. I also moved the \label inside the align.

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{amsmath}
\begin{document}
%\begin{equation}
\begin{align}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} = 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\label{system}
\end{align}
%\end{equation}
\end{document}

enter image description here

Alternately, you can keep the equation environment, and change align to aligned:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{aligned}
\begin{split}
  a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta{_n}),
\\
b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) + \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),
 \\
 \theta_{n} + \alpha_{n} + \theta^{*}_{n+1} - \alpha_{n+1} = 0,
 \\
 \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{*}_{n+1},
 \\
 \sqrt{2E_{n+1}}\sin\theta_{n+1} = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
\end{split}
\label{system}
\end{aligned}
\end{equation}
\end{document}
0

Youn don't have to nest align equation. If you want a single equation number, nest aligned or split, but not both, and use & for the alignment point. I suggest three possible layouts: either with aligned and the second, very long, line split with multlined from mathtools, or with gathered and multlined (no alignment point), or aligned but for the second line:

    \documentclass{article}
\usepackage[showframe]{geometry}
    \usepackage{mathtools, nccmath}

    \begin{document}

\begin{equation}
\begin{aligned}
 a(t_{n+1}) \cos \varphi_{n+1} & = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta_{n}), \\ b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) & = \begin{multlined}[t] b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) \\+ \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),\end{multlined} \\%
  \theta_{n} + \alpha_{n} + \theta^{}_{n+1} - \alpha_{n+1} & = 0, \\%
   \sqrt{2E_{n+1}}\cos \theta_{n+1} & = \sqrt{2E_{n}}\cos\theta^{}_{n+1}, \\%
   \sqrt{2E_{n+1}}\sin\theta_{n+1} & = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
 \end{aligned}\label{system}
 \end{equation}
\bigskip
\begin{equation}
\begin{gathered}
 a(t_{n+1}) \cos \varphi_{n+1} = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta_{n}), \\ b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = \begin{multlined}[t] b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) \\+ \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),\end{multlined} \\%
  \theta_{n} + \alpha_{n} + \theta^{}_{n+1} - \alpha_{n+1} = 0, \\%
   \sqrt{2E_{n+1}}\cos \theta_{n+1} = \sqrt{2E_{n}}\cos\theta^{}_{n+1}, \\%
   \sqrt{2E_{n+1}}\sin\theta_{n+1}= \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
 \end{gathered}\label{system}
 \end{equation}
\bigskip
 \begin{equation}
\begin{aligned}
 a(t_{n+1}) \cos \varphi_{n+1} & = a(t_{n}) \cos \varphi_{n} + \sqrt{2E_{n}}(t_{n+1} - t_{n}) \cos( \alpha_{n}+ \theta_{n}), \\ %
\MoveEqLeft[2]\mathclap{b(t_{n+1})\sin \varphi_{n+1} \left(1+ \delta \sin^{2} \varphi_{n+1} \right) = b(t_{n})\sin \varphi_{n} \left(1+ \delta \sin^{2} \varphi_{n} \right) \mathrlap{+ \sqrt{2E_{n}}(t_{n+1}-t_{n}) \sin (\alpha_{n} + \theta_{n}),}} \\%
    \theta_{n} + \alpha_{n} + \theta^{}_{n+1} - \alpha_{n+1} & = 0, \\%
     \sqrt{2E_{n+1}}\cos \theta_{n+1} & = \sqrt{2E_{n}}\cos\theta^{}_{n+1}, \\%
     \sqrt{2E_{n+1}}\sin\theta_{n+1} & = \sqrt{2E_{n}}\sin\theta^{*}_{n+1}-2u(\varphi_{n+1}, t_{n+1}).
 \end{aligned}\label{system}
 \end{equation}

    \end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.