0

The align environment is not advancing the equation counter. Here's the code that produced the output below:

\documentclass{report}

\usepackage{mathtools,amsthm}



\begin{document}
 \numberwithin{section}{chapter}
    \numberwithin{equation}{section}
    \let\realequation\equation
    \def\equation{\setcounter{equation}{\arabic{subsection}}%
       \refstepcounter{subsection}%
       \realequation}

    \theoremstyle{definition}
    \newtheorem{thm}[subsection]{Theorem}
    \newtheorem{lemma}[subsection]{Lemma}
    \newtheorem{corol}[subsection]{Corollary}
    \newtheorem{defn}[subsection]{Definition} % definition numbers are dependent on theorem numbers
    \newtheorem{defns}[subsection]{Definitions} % definition numbers are dependent on theorem numbers
    \newtheorem{prop}[subsection]{Proposition} % proposition numbers are dependent on theorem numbers
    \newtheorem{exmp}[subsection]{Example} % same for example numbers
    \newtheorem*{remark}{Remark}
    \newtheorem{enum_remark}[subsection]{Remark}
    \newtheorem{exercises}[subsection]{Exercises}
    \newtheorem*{opex}{Opening Exercises}

        \begin{align} \label{nchoosed}
            \begin{split}
            \prescript{}{n}C_d = \binom{n}{d} 
                &=  \frac{n \cdot (n-1) \cdot (n-2) \cdots (n - d + 1)}{d!} \\
                &= \frac{n!}{d! (n-d)!}
            \end{split}
        \end{align}

some text
    \begin{equation}
        a = b
    \end{equation}
\end{document}

enter image description here

The document is set up so that a single counter runs through each chapter and gets advanced by subsections, theorems, equations, etc.

5
  • the numbering is determined by code you are not showing so it is impossible to guess what is wrong. Please edit your example so that it is a complete small document that shows the problem. Jun 13, 2019 at 15:11
  • @DavidCarlisle thanks I've updated the code
    – jtbrasel
    Jun 13, 2019 at 15:40
  • well it wasn't runnable as posted but I guessed some needed packages, it doesn't make the posted image but i suppose now shows the issue Jun 13, 2019 at 15:45
  • align advances the equation counter but you have redefined equation to ignore that and use the subsection counter, so naturally they both use 1 Jun 13, 2019 at 15:48
  • ahhh, ok, so I need to redefine align so that it also uses the subsection counter?
    – jtbrasel
    Jun 13, 2019 at 15:50

1 Answer 1

1

enter image description here

align advances the equation counter but you have redefined equation to ignore that and use the subsection counter, so naturally they both use 1

This makes subsection and equation counter the same, so if any construct increases one, the value of the other will have changed.

\documentclass{report}

\usepackage{mathtools,amsthm}

 \numberwithin{section}{chapter}
 \numberwithin{equation}{section}

% make equation counter an alias for subsection
\makeatletter
\let\c@equation\c@subsection
\makeatother



    \theoremstyle{definition}
    \newtheorem{thm}[subsection]{Theorem}
    \newtheorem{lemma}[subsection]{Lemma}
    \newtheorem{corol}[subsection]{Corollary}
    \newtheorem{defn}[subsection]{Definition} % definition numbers are dependent on theorem numbers
    \newtheorem{defns}[subsection]{Definitions} % definition numbers are dependent on theorem numbers
    \newtheorem{prop}[subsection]{Proposition} % proposition numbers are dependent on theorem numbers
    \newtheorem{exmp}[subsection]{Example} % same for example numbers
    \newtheorem*{remark}{Remark}
    \newtheorem{enum_remark}[subsection]{Remark}
    \newtheorem{exercises}[subsection]{Exercises}
    \newtheorem*{opex}{Opening Exercises}

  \begin{document}

first align
      \begin{align} \label{nchoosed}
            \begin{split}
            \prescript{}{n}C_d = \binom{n}{d} 
                &=  \frac{n \cdot (n-1) \cdot (n-2) \cdots (n - d + 1)}{d!} \\
                &= \frac{n!}{d! (n-d)!}
            \end{split}
        \end{align}

some text
    \begin{equation}
        a = b
    \end{equation}

second align
      \begin{align} \label{nchoosedz}
            \begin{split}
            \prescript{}{n}C_d = \binom{n}{d} 
                &=  \frac{n \cdot (n-1) \cdot (n-2) \cdots (n - d + 1)}{d!} \\
                &= \frac{n!}{d! (n-d)!}
            \end{split}
        \end{align}

some text
    \begin{equation}
        a = b
    \end{equation}
\end{document}
1
  • Thanks so much! that's the fix.
    – jtbrasel
    Jun 13, 2019 at 16:02

You must log in to answer this question.

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