16

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
  • 1
    align is already in math mode, so get rid of the equation environment. May 30, 2017 at 12:25

3 Answers 3

16

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

5
  • Thanks! By the way, what would you do to make it look less "terrrible"? @Skillmon
    – Alex
    May 30, 2017 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, 2017 at 12:32
  • 1
    What's the usefulness of split nested in align?
    – Bernard
    May 30, 2017 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, 2017 at 13:08
  • @Skillmon: Oh! yes. Usually I do that with equation+aligned (or +split), so it seemed strange to me.
    – Bernard
    May 30, 2017 at 13:38
9

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}
2
  • Thank you, this fixed my problem when I had $$\begin{align}.....\end{align}$$. Getting rid of the $$ allowed it to typeset seamlessly
    – user71207
    Jun 15, 2021 at 2:41
  • @user71207 It is a common enough mistake for beginners to LaTeX. Another is to use $$ at all. That is a construct for TeX, and while LaTeX does not complain of it, you instead, when needed, should use \[...\] or the amsmath package \begin{equation*}...\end{equation*} when the equation is not to be numbered, and \begin{equation}...\end{equation} when it is to be numbered. The various amsmath align-style environments are for when multiple equations reside in the set. Jun 15, 2021 at 8:57
1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .