1

Does anybody here have any ideas why the following code does not seem to compile in MiKTeX 2.9? I am using the amsthm package:

   $$\begin{align}
    &1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} \\ 
    \\ &=1+(8 m - 2)\sum_{i=0}^{k}\binom{k}{i}(12m)^i + (48m^2 - 8 m  + 1)\sum_{i=0}^{2k}\binom{2k}{i}(12m)^{i} \\
    \\ &=1+(8 m - 2)\bigg(1+12km+\underbrace{\sum_{i=2}^{k}\binom{k}{i}(12m)^i}_{\text{divisible by $288m^2$}}\bigg) 
    \\ &\qquad\quad + (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}+\underbrace{\sum_{i=3}^{2k}\binom{2k}{i}(12m)^{i}}_{\text{divisible by $288m^2$}}\bigg) \\
    \\ &\equiv 1+(8 m - 2)(1+12km)
    \\ &\qquad\quad + (48m^2 - 8 m  + 1)\bigg(1+24km+\binom{2k}{2}(12m)^{2}\bigg)\pmod{288m^2} \\
    \\ &\equiv 48(k+1)m^2\pmod{288m^2}
    \end{align}$$

I have confirmed that the code renders perfectly in MathJAX. However, in TeXnicCenter, it is spitting out the following error upon compile:

latex> ! Package amsmath Error: Erroneous nesting of equation structures;
latex> (amsmath)                trying to recover with `aligned'.
latex> See the amsmath package documentation for explanation.

Please help.

  • 4
    Just remove the pair of $$, which is plain TeX syntax for a displayed equation, and shouldn't be used with LaTeX code. Also, note that MathJAX is not LaTeX. – Bernard Jul 11 '21 at 15:25
  • 3
    @Bernard removing the $$ is the right solution, but not because this is plain syntax but because align switch into display math itself. – Ulrike Fischer Jul 11 '21 at 15:28
  • My profuse thanks, @Bernard! That certainly did the trick! Please do write out your last comment as an actual answer so that I could upvote then accept, and so that this question does not remain in the unanswered queue. – Jose Arnaldo Bebita Dris Jul 11 '21 at 15:28
  • @UlrikeFischer: Indeed my formulation was rather awkward. The ‘plain TeX syntax’ was just a comment to mean that it just shouldn't be used with LaTeX code. – Bernard Jul 11 '21 at 15:37
  • 1
    @ArnieBebita-Dris: I don't think it's necessary, as I'm pretty sure there are already plenty of answers on this theme. Some more experienced user of this site will certainly close the question as ‘solved in the comments’. – Bernard Jul 11 '21 at 15:40
  • Do you want each and every row in this multiline equation to be numbered? Please advise. – Mico Jul 11 '21 at 16:16
  • @Mico: I already know how to omit equation numbers (i.e. by using \begin{align}, \end{align}.) Thank you for your time and attention! =) – Jose Arnaldo Bebita Dris Jul 11 '21 at 16:18
  • @bernard there is no solved in the comments close rule. If there’s one thing I’d change about the Tex.se culture, it’s the answers in comments trend. – Don Hosek Jul 11 '21 at 17:20

1 Answers1

0

In addition to omitting both instances of $$, you also need to (a) get rid of some of the \\ directives and (b) selectively insert \notag directives.

enter image description here

\documentclass{article} 
\usepackage{amsmath}
\begin{document}
\begin{align}
    &1+(8 m - 2) (12 m + 1)^k + (48m^2 - 8 m  + 1) (12 m + 1)^{2 k} \\ 
    &\quad=1+(8 m - 2)\sum_{i=0}^{k}\binom{k}{i}(12m)^i + 
        (48m^2 - 8 m  + 1)\sum_{i=0}^{2k}\binom{2k}{i}(12m)^{i} \\
    &\quad=1+(8 m - 2)\biggl(1+12km
        +\underbrace{\sum_{i=2}^{k}\binom{k}{i}(12m)^i}%
        _{\text{divisible by $288m^2$}}\biggr) 
        \notag\\
    &\quad\quad + (48m^2 - 8 m  + 1)\biggl(1+24km+\binom{2k}{2}(12m)^{2}
        +\underbrace{\sum_{i=3}^{2k}\binom{2k}{i}(12m)^{i}}%
        _{\text{divisible by $288m^2$}}\biggr) \\
    &\quad\equiv 1+(8 m - 2)(1+12km) \notag\\
    &\quad\quad + (48m^2 - 8 m  + 1)\biggl(1+24km+
        \binom{2k}{2}(12m)^{2}\biggr)\pmod{288m^2} \\
    &\quad\equiv 48(k+1)m^2\pmod{288m^2}\,.
\end{align}
\end{document}
Mico
  • 506,678