subequations: Equation numbering does not start with no. 1












4















The user egreg has posted a nice approach on how to increase equation numbers within subequations.





Minimum Working Example (MWE):



documentclass{article}
usepackage{amsmath}
usepackage{mathtools}

newcommand{advanceparent}{%
stepcounter{parentequation}%
setcounter{equation}{0}%
xdeftheparentequation{arabic{parentequation}}%
}

begin{document}
begin{subequations}
begin{alignat}{3}
advanceparent
&& 1 & =1 &quad & (text{Example text}) \
&& 2 & =2 & & (text{Example text}) \
advanceparent
&& 3 & =3 & & (text{Example text}) \
&& 4 & =4 & & (text{Example text})
end{alignat}
end{subequations}
end{document}




Screenshot of the result:



Screenshot of the result





Description of the issue:



As you can see in the screenshot, even the very first equation begins with no. 2 instead of no. 1. I have tried to repair this behavior, but I don't get the issue fixed.



How to fix the code so numbering will begin with no. 1 and does continue numbering order of the previous document?










share|improve this question


















  • 1





    Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

    – campa
    Apr 1 at 13:48













  • @campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

    – Dave
    Apr 1 at 13:51








  • 1





    Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

    – campa
    Apr 1 at 13:54











  • @campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

    – Dave
    Apr 1 at 13:57


















4















The user egreg has posted a nice approach on how to increase equation numbers within subequations.





Minimum Working Example (MWE):



documentclass{article}
usepackage{amsmath}
usepackage{mathtools}

newcommand{advanceparent}{%
stepcounter{parentequation}%
setcounter{equation}{0}%
xdeftheparentequation{arabic{parentequation}}%
}

begin{document}
begin{subequations}
begin{alignat}{3}
advanceparent
&& 1 & =1 &quad & (text{Example text}) \
&& 2 & =2 & & (text{Example text}) \
advanceparent
&& 3 & =3 & & (text{Example text}) \
&& 4 & =4 & & (text{Example text})
end{alignat}
end{subequations}
end{document}




Screenshot of the result:



Screenshot of the result





Description of the issue:



As you can see in the screenshot, even the very first equation begins with no. 2 instead of no. 1. I have tried to repair this behavior, but I don't get the issue fixed.



How to fix the code so numbering will begin with no. 1 and does continue numbering order of the previous document?










share|improve this question


















  • 1





    Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

    – campa
    Apr 1 at 13:48













  • @campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

    – Dave
    Apr 1 at 13:51








  • 1





    Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

    – campa
    Apr 1 at 13:54











  • @campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

    – Dave
    Apr 1 at 13:57
















4












4








4








The user egreg has posted a nice approach on how to increase equation numbers within subequations.





Minimum Working Example (MWE):



documentclass{article}
usepackage{amsmath}
usepackage{mathtools}

newcommand{advanceparent}{%
stepcounter{parentequation}%
setcounter{equation}{0}%
xdeftheparentequation{arabic{parentequation}}%
}

begin{document}
begin{subequations}
begin{alignat}{3}
advanceparent
&& 1 & =1 &quad & (text{Example text}) \
&& 2 & =2 & & (text{Example text}) \
advanceparent
&& 3 & =3 & & (text{Example text}) \
&& 4 & =4 & & (text{Example text})
end{alignat}
end{subequations}
end{document}




Screenshot of the result:



Screenshot of the result





Description of the issue:



As you can see in the screenshot, even the very first equation begins with no. 2 instead of no. 1. I have tried to repair this behavior, but I don't get the issue fixed.



How to fix the code so numbering will begin with no. 1 and does continue numbering order of the previous document?










share|improve this question














The user egreg has posted a nice approach on how to increase equation numbers within subequations.





Minimum Working Example (MWE):



documentclass{article}
usepackage{amsmath}
usepackage{mathtools}

newcommand{advanceparent}{%
stepcounter{parentequation}%
setcounter{equation}{0}%
xdeftheparentequation{arabic{parentequation}}%
}

begin{document}
begin{subequations}
begin{alignat}{3}
advanceparent
&& 1 & =1 &quad & (text{Example text}) \
&& 2 & =2 & & (text{Example text}) \
advanceparent
&& 3 & =3 & & (text{Example text}) \
&& 4 & =4 & & (text{Example text})
end{alignat}
end{subequations}
end{document}




Screenshot of the result:



Screenshot of the result





Description of the issue:



As you can see in the screenshot, even the very first equation begins with no. 2 instead of no. 1. I have tried to repair this behavior, but I don't get the issue fixed.



How to fix the code so numbering will begin with no. 1 and does continue numbering order of the previous document?







equations numbering amsmath subequations alignat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 1 at 13:43









DaveDave

1,236619




1,236619








  • 1





    Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

    – campa
    Apr 1 at 13:48













  • @campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

    – Dave
    Apr 1 at 13:51








  • 1





    Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

    – campa
    Apr 1 at 13:54











  • @campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

    – Dave
    Apr 1 at 13:57
















  • 1





    Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

    – campa
    Apr 1 at 13:48













  • @campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

    – Dave
    Apr 1 at 13:51








  • 1





    Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

    – campa
    Apr 1 at 13:54











  • @campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

    – Dave
    Apr 1 at 13:57










1




1





Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

– campa
Apr 1 at 13:48







Well, the advanceparent makes sense only in the middle of subequations, not at the very beginning...

– campa
Apr 1 at 13:48















@campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

– Dave
Apr 1 at 13:51







@campa: Yes, I thought the same. But even removing the very first advanceparent-part does not change the numbering scheme.

– Dave
Apr 1 at 13:51






1




1





Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

– campa
Apr 1 at 13:54





Yes, that's one of the possible xdef vs gdef issues @daleif meant in his answer to your previous question :-)

– campa
Apr 1 at 13:54













@campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

– Dave
Apr 1 at 13:57







@campa: Oh my... :-) Sometimes LaTeX is everything else but not handy. :-)

– Dave
Apr 1 at 13:57












2 Answers
2






active

oldest

votes


















2














The subequations environment allows to use label just after it starts, in order to refer to the parent number globally. The idea is exploited in the linked answer.



You don't need this, so you have to explicitly start the business.



documentclass{article}
usepackage{amsmath}
usepackage{mathtools}
usepackage{etoolbox}

newcommand{advanceparent}{%
stepcounter{parentequation}%
startparent
}
newcommand{startparent}{%
setcounter{equation}{0}%
xdeftheparentequation{arabic{parentequation}}%
}

begin{document}

begin{subequations}
begin{alignat}{2}
startparent
1 & =1 &quad & text{(Example text)} \
2 & =2 & & text{(Example text)} \
advanceparent
3 & =3 & & text{(Example text)} \
4 & =4 & & text{(Example text)}
end{alignat}
end{subequations}
end{document}


enter image description here






share|improve this answer































    1














    You can decrease the counter inside of the subequation environment:



    documentclass{article}
    usepackage{amsmath}
    usepackage{mathtools}

    newcommand{advanceparent}{%
    stepcounter{parentequation}%
    setcounter{equation}{0}%
    xdeftheparentequation{arabic{parentequation}}%
    }

    begin{document}
    begin{subequations}
    addtocounter{parentequation}{-1}%
    begin{alignat}{3}
    advanceparent
    && 1 & =1 &quad & (text{Example text}) \
    && 2 & =2 & & (text{Example text}) \
    advanceparent
    && 3 & =3 & & (text{Example text}) \
    && 4 & =4 & & (text{Example text})
    end{alignat}
    end{subequations}

    end{document}


    enter image description here



    If you don't want to do that manually at every set of equations, then you can hook it into the environment with etoolbox. In the example I have used the begin of alignat because the begin of subequations is still too early (the counter is setup after that).



    documentclass{article}
    usepackage{amsmath}
    usepackage{mathtools}

    usepackage{etoolbox}
    AtBeginEnvironment{alignat}{addtocounter{parentequation}{-1}}

    newcommand{advanceparent}{%
    stepcounter{parentequation}%
    setcounter{equation}{0}%
    xdeftheparentequation{arabic{parentequation}}%
    }

    begin{document}
    begin{subequations}
    %addtocounter{parentequation}{-1}% no longer needed
    begin{alignat}{3}
    advanceparent
    && 1 & =1 &quad & (text{Example text}) \
    && 2 & =2 & & (text{Example text}) \
    advanceparent
    && 3 & =3 & & (text{Example text}) \
    && 4 & =4 & & (text{Example text})
    end{alignat}
    end{subequations}

    end{document}





    share|improve this answer
























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "85"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482588%2fsubequations-equation-numbering-does-not-start-with-no-1%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      The subequations environment allows to use label just after it starts, in order to refer to the parent number globally. The idea is exploited in the linked answer.



      You don't need this, so you have to explicitly start the business.



      documentclass{article}
      usepackage{amsmath}
      usepackage{mathtools}
      usepackage{etoolbox}

      newcommand{advanceparent}{%
      stepcounter{parentequation}%
      startparent
      }
      newcommand{startparent}{%
      setcounter{equation}{0}%
      xdeftheparentequation{arabic{parentequation}}%
      }

      begin{document}

      begin{subequations}
      begin{alignat}{2}
      startparent
      1 & =1 &quad & text{(Example text)} \
      2 & =2 & & text{(Example text)} \
      advanceparent
      3 & =3 & & text{(Example text)} \
      4 & =4 & & text{(Example text)}
      end{alignat}
      end{subequations}
      end{document}


      enter image description here






      share|improve this answer




























        2














        The subequations environment allows to use label just after it starts, in order to refer to the parent number globally. The idea is exploited in the linked answer.



        You don't need this, so you have to explicitly start the business.



        documentclass{article}
        usepackage{amsmath}
        usepackage{mathtools}
        usepackage{etoolbox}

        newcommand{advanceparent}{%
        stepcounter{parentequation}%
        startparent
        }
        newcommand{startparent}{%
        setcounter{equation}{0}%
        xdeftheparentequation{arabic{parentequation}}%
        }

        begin{document}

        begin{subequations}
        begin{alignat}{2}
        startparent
        1 & =1 &quad & text{(Example text)} \
        2 & =2 & & text{(Example text)} \
        advanceparent
        3 & =3 & & text{(Example text)} \
        4 & =4 & & text{(Example text)}
        end{alignat}
        end{subequations}
        end{document}


        enter image description here






        share|improve this answer


























          2












          2








          2







          The subequations environment allows to use label just after it starts, in order to refer to the parent number globally. The idea is exploited in the linked answer.



          You don't need this, so you have to explicitly start the business.



          documentclass{article}
          usepackage{amsmath}
          usepackage{mathtools}
          usepackage{etoolbox}

          newcommand{advanceparent}{%
          stepcounter{parentequation}%
          startparent
          }
          newcommand{startparent}{%
          setcounter{equation}{0}%
          xdeftheparentequation{arabic{parentequation}}%
          }

          begin{document}

          begin{subequations}
          begin{alignat}{2}
          startparent
          1 & =1 &quad & text{(Example text)} \
          2 & =2 & & text{(Example text)} \
          advanceparent
          3 & =3 & & text{(Example text)} \
          4 & =4 & & text{(Example text)}
          end{alignat}
          end{subequations}
          end{document}


          enter image description here






          share|improve this answer













          The subequations environment allows to use label just after it starts, in order to refer to the parent number globally. The idea is exploited in the linked answer.



          You don't need this, so you have to explicitly start the business.



          documentclass{article}
          usepackage{amsmath}
          usepackage{mathtools}
          usepackage{etoolbox}

          newcommand{advanceparent}{%
          stepcounter{parentequation}%
          startparent
          }
          newcommand{startparent}{%
          setcounter{equation}{0}%
          xdeftheparentequation{arabic{parentequation}}%
          }

          begin{document}

          begin{subequations}
          begin{alignat}{2}
          startparent
          1 & =1 &quad & text{(Example text)} \
          2 & =2 & & text{(Example text)} \
          advanceparent
          3 & =3 & & text{(Example text)} \
          4 & =4 & & text{(Example text)}
          end{alignat}
          end{subequations}
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 1 at 21:34









          egregegreg

          733k8919313254




          733k8919313254























              1














              You can decrease the counter inside of the subequation environment:



              documentclass{article}
              usepackage{amsmath}
              usepackage{mathtools}

              newcommand{advanceparent}{%
              stepcounter{parentequation}%
              setcounter{equation}{0}%
              xdeftheparentequation{arabic{parentequation}}%
              }

              begin{document}
              begin{subequations}
              addtocounter{parentequation}{-1}%
              begin{alignat}{3}
              advanceparent
              && 1 & =1 &quad & (text{Example text}) \
              && 2 & =2 & & (text{Example text}) \
              advanceparent
              && 3 & =3 & & (text{Example text}) \
              && 4 & =4 & & (text{Example text})
              end{alignat}
              end{subequations}

              end{document}


              enter image description here



              If you don't want to do that manually at every set of equations, then you can hook it into the environment with etoolbox. In the example I have used the begin of alignat because the begin of subequations is still too early (the counter is setup after that).



              documentclass{article}
              usepackage{amsmath}
              usepackage{mathtools}

              usepackage{etoolbox}
              AtBeginEnvironment{alignat}{addtocounter{parentequation}{-1}}

              newcommand{advanceparent}{%
              stepcounter{parentequation}%
              setcounter{equation}{0}%
              xdeftheparentequation{arabic{parentequation}}%
              }

              begin{document}
              begin{subequations}
              %addtocounter{parentequation}{-1}% no longer needed
              begin{alignat}{3}
              advanceparent
              && 1 & =1 &quad & (text{Example text}) \
              && 2 & =2 & & (text{Example text}) \
              advanceparent
              && 3 & =3 & & (text{Example text}) \
              && 4 & =4 & & (text{Example text})
              end{alignat}
              end{subequations}

              end{document}





              share|improve this answer




























                1














                You can decrease the counter inside of the subequation environment:



                documentclass{article}
                usepackage{amsmath}
                usepackage{mathtools}

                newcommand{advanceparent}{%
                stepcounter{parentequation}%
                setcounter{equation}{0}%
                xdeftheparentequation{arabic{parentequation}}%
                }

                begin{document}
                begin{subequations}
                addtocounter{parentequation}{-1}%
                begin{alignat}{3}
                advanceparent
                && 1 & =1 &quad & (text{Example text}) \
                && 2 & =2 & & (text{Example text}) \
                advanceparent
                && 3 & =3 & & (text{Example text}) \
                && 4 & =4 & & (text{Example text})
                end{alignat}
                end{subequations}

                end{document}


                enter image description here



                If you don't want to do that manually at every set of equations, then you can hook it into the environment with etoolbox. In the example I have used the begin of alignat because the begin of subequations is still too early (the counter is setup after that).



                documentclass{article}
                usepackage{amsmath}
                usepackage{mathtools}

                usepackage{etoolbox}
                AtBeginEnvironment{alignat}{addtocounter{parentequation}{-1}}

                newcommand{advanceparent}{%
                stepcounter{parentequation}%
                setcounter{equation}{0}%
                xdeftheparentequation{arabic{parentequation}}%
                }

                begin{document}
                begin{subequations}
                %addtocounter{parentequation}{-1}% no longer needed
                begin{alignat}{3}
                advanceparent
                && 1 & =1 &quad & (text{Example text}) \
                && 2 & =2 & & (text{Example text}) \
                advanceparent
                && 3 & =3 & & (text{Example text}) \
                && 4 & =4 & & (text{Example text})
                end{alignat}
                end{subequations}

                end{document}





                share|improve this answer


























                  1












                  1








                  1







                  You can decrease the counter inside of the subequation environment:



                  documentclass{article}
                  usepackage{amsmath}
                  usepackage{mathtools}

                  newcommand{advanceparent}{%
                  stepcounter{parentequation}%
                  setcounter{equation}{0}%
                  xdeftheparentequation{arabic{parentequation}}%
                  }

                  begin{document}
                  begin{subequations}
                  addtocounter{parentequation}{-1}%
                  begin{alignat}{3}
                  advanceparent
                  && 1 & =1 &quad & (text{Example text}) \
                  && 2 & =2 & & (text{Example text}) \
                  advanceparent
                  && 3 & =3 & & (text{Example text}) \
                  && 4 & =4 & & (text{Example text})
                  end{alignat}
                  end{subequations}

                  end{document}


                  enter image description here



                  If you don't want to do that manually at every set of equations, then you can hook it into the environment with etoolbox. In the example I have used the begin of alignat because the begin of subequations is still too early (the counter is setup after that).



                  documentclass{article}
                  usepackage{amsmath}
                  usepackage{mathtools}

                  usepackage{etoolbox}
                  AtBeginEnvironment{alignat}{addtocounter{parentequation}{-1}}

                  newcommand{advanceparent}{%
                  stepcounter{parentequation}%
                  setcounter{equation}{0}%
                  xdeftheparentequation{arabic{parentequation}}%
                  }

                  begin{document}
                  begin{subequations}
                  %addtocounter{parentequation}{-1}% no longer needed
                  begin{alignat}{3}
                  advanceparent
                  && 1 & =1 &quad & (text{Example text}) \
                  && 2 & =2 & & (text{Example text}) \
                  advanceparent
                  && 3 & =3 & & (text{Example text}) \
                  && 4 & =4 & & (text{Example text})
                  end{alignat}
                  end{subequations}

                  end{document}





                  share|improve this answer













                  You can decrease the counter inside of the subequation environment:



                  documentclass{article}
                  usepackage{amsmath}
                  usepackage{mathtools}

                  newcommand{advanceparent}{%
                  stepcounter{parentequation}%
                  setcounter{equation}{0}%
                  xdeftheparentequation{arabic{parentequation}}%
                  }

                  begin{document}
                  begin{subequations}
                  addtocounter{parentequation}{-1}%
                  begin{alignat}{3}
                  advanceparent
                  && 1 & =1 &quad & (text{Example text}) \
                  && 2 & =2 & & (text{Example text}) \
                  advanceparent
                  && 3 & =3 & & (text{Example text}) \
                  && 4 & =4 & & (text{Example text})
                  end{alignat}
                  end{subequations}

                  end{document}


                  enter image description here



                  If you don't want to do that manually at every set of equations, then you can hook it into the environment with etoolbox. In the example I have used the begin of alignat because the begin of subequations is still too early (the counter is setup after that).



                  documentclass{article}
                  usepackage{amsmath}
                  usepackage{mathtools}

                  usepackage{etoolbox}
                  AtBeginEnvironment{alignat}{addtocounter{parentequation}{-1}}

                  newcommand{advanceparent}{%
                  stepcounter{parentequation}%
                  setcounter{equation}{0}%
                  xdeftheparentequation{arabic{parentequation}}%
                  }

                  begin{document}
                  begin{subequations}
                  %addtocounter{parentequation}{-1}% no longer needed
                  begin{alignat}{3}
                  advanceparent
                  && 1 & =1 &quad & (text{Example text}) \
                  && 2 & =2 & & (text{Example text}) \
                  advanceparent
                  && 3 & =3 & & (text{Example text}) \
                  && 4 & =4 & & (text{Example text})
                  end{alignat}
                  end{subequations}

                  end{document}






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Apr 1 at 14:01









                  MarijnMarijn

                  8,479639




                  8,479639






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f482588%2fsubequations-equation-numbering-does-not-start-with-no-1%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                      How to change which sound is reproduced for terminal bell?

                      Can I use Tabulator js library in my java Spring + Thymeleaf project?