Results 1 to 6 of 6

Math Help - scrbook & amsmath: wrong equation numbering in appendix

  1. #1
    Newbie
    Joined
    Sep 2010
    Posts
    18

    scrbook & amsmath: wrong equation numbering in appendix

    Hi everybody,

    I'm facing a curious problem: Using "\numberwithin{equation}{section}", equation numbering starts at "1" in each new section ((1.1.1), (1.1.2), (1.2.1), ...) and that's fine. In the appendix, however, I switch to "\numberwithin{equation}{chapter}" and expect a numbering ((A.1), (A.2), (B.1), (B.2), ...). This indeed works as long as I refrain from adding sections in the appendix: a new \section in an appendix-chapter (labeled by "A") leads to ambiguous numbering: ((A.1), (A.2), "\section", (A.1), (A.2), (B.1), (B.2), ...).

    Strangely, changing "\numberwithin{equation}{section}" to "\numberwithin{equation}{chapter}" leads to correct numbering in the appendix. But I'd like to have sectionwise-numbering in the mainmatter.

    How do get \numberwithin to work properly?

    A 'next-to-minimum' example is attached.


    Thanks for helping!
    Attached Files Attached Files
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,537
    Thanks
    778
    So you want to number equations by section in the main matter and by chapter in the appendix? This TeX FAQ talks about it.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor
    Opalg's Avatar
    Joined
    Aug 2007
    From
    Leeds, UK
    Posts
    4,041
    Thanks
    7
    If I understand this correctly, you want the equation numbers at the start of the Appendix to look like (A.1), (A.2), ... . Then when a Section of the Appendix starts, you want the numbering to look like (A.1.1), (A.1.2), ... .

    If that is indeed what you want, you cannot get it by simple \numberwithin commands. What you need to do is to replace the command \numberwithin{equation}{chapter} (just after the \appendix line) with this:

    Code:
    \renewcommand{\theequation}{\thechapter.\ifnum\value{section} > 0 \arabic{section}.\fi\arabic{equation}}
    That way, you will get an output with three components (A.x.y), except that the middle component (the section number) will be suppressed if it is equal to 0.

    Edit. On the other hand, if you want the equation numbers in the Appendix to have just two components, of the form (A.x), regardless of whether there are Sections or not, you need to install a \removefromreset command. Insert this code in the preamble of your file (just before \begin{document}):

    Code:
    \makeatletter
    \def\removefromreset#1#2{{%
      \expandafter\let\csname c@#1\endcsname\removefromreset
      \def\@elt##1{%
        \expandafter\ifx\csname c@##1\endcsname\removefromreset
        \else
          \noexpand\@elt{##1}%
        \fi}%
      \expandafter\xdef\csname cl@#2\endcsname{%
        \csname cl@#2\endcsname}}}
    \makeatother
    Then, at the start of the Appendix, insert the command \removefromreset{equation}{section} immediately before the line \numberwithin{equation}{chapter}.
    Last edited by Opalg; November 12th 2010 at 07:09 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Sep 2010
    Posts
    18
    I'd like to have something like that:

    Code:
    CHAPTER ONE:
    Section one
        eq(1.1.1)
        eq(1.1.2)
    Section two
        eq(1.2.1)
        eq(1.2.2)
    APPENDIX CHAPTER ONE
        eq(A.1)
    appendix section one
        eq(A.2)*
        eq(A.3)
    appendix section two
        eq(A.4)*
        eq(A.5)
    So within the main part, the section number is used for numbering equations and numbering restarts each section. But in the appendix I don't need the section number for equation numbering. And most importantly, equation numbering should NOT restart each new section. But this is what happens: every numer marked with a asterisk is labeled (A.1).

    I wrote
    Code:
    \numberwithin{equation}{section}
    at the beginning of the main part and this works perfectly for the main part (it looks like the example above).

    As I understand \numberwithin, a simple statement
    Code:
    \numberwithin{equation}{chapter}
    at the beginning of the appendix ought to do the trick (restart numbering each chapter, no section number for numbering equations), but somehow it doesn't work (no section number for numbering equations is ok, but numbering still restarts each section).

    I hope this clearifies my problem. So, what's wrong with \numberwithin? I'd like to understand why LaTeX does what it does and how to fix this straightforward (without workarounds). At least if possible.

    Thanks again!
    Last edited by needsomemathhelp; November 12th 2010 at 07:09 AM. Reason: fixed typo
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor
    Joined
    Oct 2009
    Posts
    5,537
    Thanks
    778
    In my experiment, saying

    \counterwithout{equation}{section}
    \counterwithin{equation}{chapter}

    inside the appendix produces the result you want.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Sep 2010
    Posts
    18
    You're right emakarov, it works. Thanks for your quick responses!

    Yet, is this a bug in numberwithin? Doesn't the "chapter" in \numberwithin{equation}{chapter} state that numbering is reset each "chapter"?
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Gödel numbering
    Posted in the Discrete Math Forum
    Replies: 2
    Last Post: October 19th 2011, 09:36 PM
  2. Godel Numbering
    Posted in the Number Theory Forum
    Replies: 6
    Last Post: February 24th 2011, 12:26 PM
  3. Equation numbering
    Posted in the LaTeX Help Forum
    Replies: 0
    Last Post: April 24th 2010, 12:53 AM
  4. Amsmath & 2 thing
    Posted in the LaTeX Help Forum
    Replies: 5
    Last Post: October 18th 2009, 10:40 AM
  5. Replies: 6
    Last Post: August 12th 2009, 02:15 AM

Search Tags


/mathhelpforum @mathhelpforum