Counting chapters and appendices












8














During my last experiences with cross-referencing on total counts between different files, a problem of counting of chapters and appendices appears.



As a MWE we can use a MWE given here with some modifications.



It happens that a simple command like setcounter{truechapters}{value{totalchapters}-value{chapter}} does not work.



I guess, that the reason is in a wrong using of these values.



The question is how to get three counts (total chapters, appendices and true chapters) in one pdf in a simple and reasonable way?



Note, please, also that I cannot use zlabel like it is described by Heiko here



Here is my MWE:



MyBook.tex:



documentclass{memoir}
usepackage{totcount}
usepackage{assoccnt}

newtotcounter{totalchapters}
DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
regtotcounter{chapter}
}

newcounter{truechapters}


begin{document}

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}


There are total{totalchapters} total chapters.


There are total{chapter} appendix chapters.


%here we need to count the difference of two previous counters
%setcounter{truechapters}{value{totalchapters}-value{chapter}}


There are thetruechapters : true chapters.



end{document}


A screenshot of MyBook.pdf is below:



enter image description here










share|improve this question
























  • Please change for future purposes to xassoccnt. I won't update assoccnt
    – Christian Hupfer
    Apr 15 '17 at 16:46


















8














During my last experiences with cross-referencing on total counts between different files, a problem of counting of chapters and appendices appears.



As a MWE we can use a MWE given here with some modifications.



It happens that a simple command like setcounter{truechapters}{value{totalchapters}-value{chapter}} does not work.



I guess, that the reason is in a wrong using of these values.



The question is how to get three counts (total chapters, appendices and true chapters) in one pdf in a simple and reasonable way?



Note, please, also that I cannot use zlabel like it is described by Heiko here



Here is my MWE:



MyBook.tex:



documentclass{memoir}
usepackage{totcount}
usepackage{assoccnt}

newtotcounter{totalchapters}
DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
regtotcounter{chapter}
}

newcounter{truechapters}


begin{document}

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}


There are total{totalchapters} total chapters.


There are total{chapter} appendix chapters.


%here we need to count the difference of two previous counters
%setcounter{truechapters}{value{totalchapters}-value{chapter}}


There are thetruechapters : true chapters.



end{document}


A screenshot of MyBook.pdf is below:



enter image description here










share|improve this question
























  • Please change for future purposes to xassoccnt. I won't update assoccnt
    – Christian Hupfer
    Apr 15 '17 at 16:46
















8












8








8


1





During my last experiences with cross-referencing on total counts between different files, a problem of counting of chapters and appendices appears.



As a MWE we can use a MWE given here with some modifications.



It happens that a simple command like setcounter{truechapters}{value{totalchapters}-value{chapter}} does not work.



I guess, that the reason is in a wrong using of these values.



The question is how to get three counts (total chapters, appendices and true chapters) in one pdf in a simple and reasonable way?



Note, please, also that I cannot use zlabel like it is described by Heiko here



Here is my MWE:



MyBook.tex:



documentclass{memoir}
usepackage{totcount}
usepackage{assoccnt}

newtotcounter{totalchapters}
DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
regtotcounter{chapter}
}

newcounter{truechapters}


begin{document}

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}


There are total{totalchapters} total chapters.


There are total{chapter} appendix chapters.


%here we need to count the difference of two previous counters
%setcounter{truechapters}{value{totalchapters}-value{chapter}}


There are thetruechapters : true chapters.



end{document}


A screenshot of MyBook.pdf is below:



enter image description here










share|improve this question















During my last experiences with cross-referencing on total counts between different files, a problem of counting of chapters and appendices appears.



As a MWE we can use a MWE given here with some modifications.



It happens that a simple command like setcounter{truechapters}{value{totalchapters}-value{chapter}} does not work.



I guess, that the reason is in a wrong using of these values.



The question is how to get three counts (total chapters, appendices and true chapters) in one pdf in a simple and reasonable way?



Note, please, also that I cannot use zlabel like it is described by Heiko here



Here is my MWE:



MyBook.tex:



documentclass{memoir}
usepackage{totcount}
usepackage{assoccnt}

newtotcounter{totalchapters}
DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
regtotcounter{chapter}
}

newcounter{truechapters}


begin{document}

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}


There are total{totalchapters} total chapters.


There are total{chapter} appendix chapters.


%here we need to count the difference of two previous counters
%setcounter{truechapters}{value{totalchapters}-value{chapter}}


There are thetruechapters : true chapters.



end{document}


A screenshot of MyBook.pdf is below:



enter image description here







memoir counters totcount assoccnt xassoccnt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:36









Community

1




1










asked Nov 16 '16 at 13:55









Vladimir Parkhomenko

110214




110214












  • Please change for future purposes to xassoccnt. I won't update assoccnt
    – Christian Hupfer
    Apr 15 '17 at 16:46




















  • Please change for future purposes to xassoccnt. I won't update assoccnt
    – Christian Hupfer
    Apr 15 '17 at 16:46


















Please change for future purposes to xassoccnt. I won't update assoccnt
– Christian Hupfer
Apr 15 '17 at 16:46






Please change for future purposes to xassoccnt. I won't update assoccnt
– Christian Hupfer
Apr 15 '17 at 16:46












3 Answers
3






active

oldest

votes


















7














You can use both the LaTeX2e-kernel-macro addtocounter and the
eTeX-primitive numexpr for calculations.



documentclass{memoir}
usepackage{totcount}
usepackage{assoccnt}

newtotcounter{totalchapters}
DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

AtBeginDocument{
%% register a counter on the basis of the last chapter in totcounter
regtotcounter{chapter}
}
newcounter{truechapters}

begin{document}

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}

There are total{totalchapters} total chapters.

There are total{chapter} appendix chapters.

%here we need to count the difference of two previous counters
setcounter{truechapters}{value{totalchapters}}%
addtocounter{truechapters}{-value{chapter}}%

There are thetruechapters : true chapters.

setcounter{truechapters}{numexprvalue{totalchapters}-value{chapter}relax}%

There are thetruechapters : true chapters.

end{document}





share|improve this answer























  • @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
    – Vladimir Parkhomenko
    Nov 17 '16 at 12:56






  • 1




    @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
    – Stefan Pinnow
    Nov 17 '16 at 16:16



















6














Define three new counters, for the main chapters, for the appendix and for the total.



The trick here is to add code to appendix for saving the number of chapters so far in truechapters and resetting the counter for the number of appendices.



documentclass{memoir}
usepackage{etoolbox}
usepackage{totcount,assoccnt}

newcounter{truechapters}
regtotcounter{truechapters}

newcounter{totalchapters}
newcounter{appendixchapters}
DeclareAssociatedCounters{chapter}{totalchapters,appendixchapters}
regtotcounter{totalchapters}
regtotcounter{appendixchapters}

pretoappendix{%
% save the number of true chapters
setcounter{truechapters}{value{chapter}}%
% reset the number of chapters
setcounter{appendixchapters}{0}%
}


begin{document}

frontmatter

There are total{totalchapters} total chapters.

There are total{appendixchapters} appendix chapters.

There are total{truechapters} true chapters.

mainmatter

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}

end{document}


enter image description here






share|improve this answer





















  • @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
    – Vladimir Parkhomenko
    Nov 24 '16 at 17:10



















6














A variant of egreg's solution, this time using the up-to-date xassoccnt package (being the successor of assoccnt), which has a partial support for total counters.



documentclass{memoir}
usepackage{xassoccnt}% Version 1.2 or higher, current version is 1.7

NewTotalDocumentCounter{appendixchapters}
DeclareTotalAssociatedCounters{chapter}{truechapters,totalchapters}

makeatletter
g@addto@macroappendix{%
SuspendCounters{truechapters}
AddAssociatedCounters{chapter}{appendixchapters}
}
makeatother

begin{document}

frontmatter

There are TotalValue{totalchapters} total chapters.

There are TotalValue{appendixchapters} appendix chapters.

There are TotalValue{truechapters} true chapters.

mainmatter

chapter{A}
chapter{B}
appendix
chapter{C}
chapter{D}
chapter{E}
chapter{F}
chapter{G}
chapter{H}
chapter{I}

end{document}


enter image description here






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%2f339439%2fcounting-chapters-and-appendices%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    You can use both the LaTeX2e-kernel-macro addtocounter and the
    eTeX-primitive numexpr for calculations.



    documentclass{memoir}
    usepackage{totcount}
    usepackage{assoccnt}

    newtotcounter{totalchapters}
    DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

    AtBeginDocument{
    %% register a counter on the basis of the last chapter in totcounter
    regtotcounter{chapter}
    }
    newcounter{truechapters}

    begin{document}

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    There are total{totalchapters} total chapters.

    There are total{chapter} appendix chapters.

    %here we need to count the difference of two previous counters
    setcounter{truechapters}{value{totalchapters}}%
    addtocounter{truechapters}{-value{chapter}}%

    There are thetruechapters : true chapters.

    setcounter{truechapters}{numexprvalue{totalchapters}-value{chapter}relax}%

    There are thetruechapters : true chapters.

    end{document}





    share|improve this answer























    • @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
      – Vladimir Parkhomenko
      Nov 17 '16 at 12:56






    • 1




      @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
      – Stefan Pinnow
      Nov 17 '16 at 16:16
















    7














    You can use both the LaTeX2e-kernel-macro addtocounter and the
    eTeX-primitive numexpr for calculations.



    documentclass{memoir}
    usepackage{totcount}
    usepackage{assoccnt}

    newtotcounter{totalchapters}
    DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

    AtBeginDocument{
    %% register a counter on the basis of the last chapter in totcounter
    regtotcounter{chapter}
    }
    newcounter{truechapters}

    begin{document}

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    There are total{totalchapters} total chapters.

    There are total{chapter} appendix chapters.

    %here we need to count the difference of two previous counters
    setcounter{truechapters}{value{totalchapters}}%
    addtocounter{truechapters}{-value{chapter}}%

    There are thetruechapters : true chapters.

    setcounter{truechapters}{numexprvalue{totalchapters}-value{chapter}relax}%

    There are thetruechapters : true chapters.

    end{document}





    share|improve this answer























    • @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
      – Vladimir Parkhomenko
      Nov 17 '16 at 12:56






    • 1




      @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
      – Stefan Pinnow
      Nov 17 '16 at 16:16














    7












    7








    7






    You can use both the LaTeX2e-kernel-macro addtocounter and the
    eTeX-primitive numexpr for calculations.



    documentclass{memoir}
    usepackage{totcount}
    usepackage{assoccnt}

    newtotcounter{totalchapters}
    DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

    AtBeginDocument{
    %% register a counter on the basis of the last chapter in totcounter
    regtotcounter{chapter}
    }
    newcounter{truechapters}

    begin{document}

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    There are total{totalchapters} total chapters.

    There are total{chapter} appendix chapters.

    %here we need to count the difference of two previous counters
    setcounter{truechapters}{value{totalchapters}}%
    addtocounter{truechapters}{-value{chapter}}%

    There are thetruechapters : true chapters.

    setcounter{truechapters}{numexprvalue{totalchapters}-value{chapter}relax}%

    There are thetruechapters : true chapters.

    end{document}





    share|improve this answer














    You can use both the LaTeX2e-kernel-macro addtocounter and the
    eTeX-primitive numexpr for calculations.



    documentclass{memoir}
    usepackage{totcount}
    usepackage{assoccnt}

    newtotcounter{totalchapters}
    DeclareAssociatedCounters{chapter}{totalchapters} % Associate the driven counter `totalchapters` to the master counter `chapter`

    AtBeginDocument{
    %% register a counter on the basis of the last chapter in totcounter
    regtotcounter{chapter}
    }
    newcounter{truechapters}

    begin{document}

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    There are total{totalchapters} total chapters.

    There are total{chapter} appendix chapters.

    %here we need to count the difference of two previous counters
    setcounter{truechapters}{value{totalchapters}}%
    addtocounter{truechapters}{-value{chapter}}%

    There are thetruechapters : true chapters.

    setcounter{truechapters}{numexprvalue{totalchapters}-value{chapter}relax}%

    There are thetruechapters : true chapters.

    end{document}






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 17 '16 at 15:11

























    answered Nov 16 '16 at 14:27









    Ulrich Diez

    4,085615




    4,085615












    • @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
      – Vladimir Parkhomenko
      Nov 17 '16 at 12:56






    • 1




      @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
      – Stefan Pinnow
      Nov 17 '16 at 16:16


















    • @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
      – Vladimir Parkhomenko
      Nov 17 '16 at 12:56






    • 1




      @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
      – Stefan Pinnow
      Nov 17 '16 at 16:16
















    @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
    – Vladimir Parkhomenko
    Nov 17 '16 at 12:56




    @ Ulrich Diez, thank you for the explanations! I have just updated the question and deleted all bugs in counter's abbreviations.
    – Vladimir Parkhomenko
    Nov 17 '16 at 12:56




    1




    1




    @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
    – Stefan Pinnow
    Nov 17 '16 at 16:16




    @UlrichDiez, the edit you are talking about was mainly edited by Vladimir and I am not sure, what I have done except approving the edit. Sorry, if the edit of Vladimir that I approved was not in your sense.
    – Stefan Pinnow
    Nov 17 '16 at 16:16











    6














    Define three new counters, for the main chapters, for the appendix and for the total.



    The trick here is to add code to appendix for saving the number of chapters so far in truechapters and resetting the counter for the number of appendices.



    documentclass{memoir}
    usepackage{etoolbox}
    usepackage{totcount,assoccnt}

    newcounter{truechapters}
    regtotcounter{truechapters}

    newcounter{totalchapters}
    newcounter{appendixchapters}
    DeclareAssociatedCounters{chapter}{totalchapters,appendixchapters}
    regtotcounter{totalchapters}
    regtotcounter{appendixchapters}

    pretoappendix{%
    % save the number of true chapters
    setcounter{truechapters}{value{chapter}}%
    % reset the number of chapters
    setcounter{appendixchapters}{0}%
    }


    begin{document}

    frontmatter

    There are total{totalchapters} total chapters.

    There are total{appendixchapters} appendix chapters.

    There are total{truechapters} true chapters.

    mainmatter

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    end{document}


    enter image description here






    share|improve this answer





















    • @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
      – Vladimir Parkhomenko
      Nov 24 '16 at 17:10
















    6














    Define three new counters, for the main chapters, for the appendix and for the total.



    The trick here is to add code to appendix for saving the number of chapters so far in truechapters and resetting the counter for the number of appendices.



    documentclass{memoir}
    usepackage{etoolbox}
    usepackage{totcount,assoccnt}

    newcounter{truechapters}
    regtotcounter{truechapters}

    newcounter{totalchapters}
    newcounter{appendixchapters}
    DeclareAssociatedCounters{chapter}{totalchapters,appendixchapters}
    regtotcounter{totalchapters}
    regtotcounter{appendixchapters}

    pretoappendix{%
    % save the number of true chapters
    setcounter{truechapters}{value{chapter}}%
    % reset the number of chapters
    setcounter{appendixchapters}{0}%
    }


    begin{document}

    frontmatter

    There are total{totalchapters} total chapters.

    There are total{appendixchapters} appendix chapters.

    There are total{truechapters} true chapters.

    mainmatter

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    end{document}


    enter image description here






    share|improve this answer





















    • @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
      – Vladimir Parkhomenko
      Nov 24 '16 at 17:10














    6












    6








    6






    Define three new counters, for the main chapters, for the appendix and for the total.



    The trick here is to add code to appendix for saving the number of chapters so far in truechapters and resetting the counter for the number of appendices.



    documentclass{memoir}
    usepackage{etoolbox}
    usepackage{totcount,assoccnt}

    newcounter{truechapters}
    regtotcounter{truechapters}

    newcounter{totalchapters}
    newcounter{appendixchapters}
    DeclareAssociatedCounters{chapter}{totalchapters,appendixchapters}
    regtotcounter{totalchapters}
    regtotcounter{appendixchapters}

    pretoappendix{%
    % save the number of true chapters
    setcounter{truechapters}{value{chapter}}%
    % reset the number of chapters
    setcounter{appendixchapters}{0}%
    }


    begin{document}

    frontmatter

    There are total{totalchapters} total chapters.

    There are total{appendixchapters} appendix chapters.

    There are total{truechapters} true chapters.

    mainmatter

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    end{document}


    enter image description here






    share|improve this answer












    Define three new counters, for the main chapters, for the appendix and for the total.



    The trick here is to add code to appendix for saving the number of chapters so far in truechapters and resetting the counter for the number of appendices.



    documentclass{memoir}
    usepackage{etoolbox}
    usepackage{totcount,assoccnt}

    newcounter{truechapters}
    regtotcounter{truechapters}

    newcounter{totalchapters}
    newcounter{appendixchapters}
    DeclareAssociatedCounters{chapter}{totalchapters,appendixchapters}
    regtotcounter{totalchapters}
    regtotcounter{appendixchapters}

    pretoappendix{%
    % save the number of true chapters
    setcounter{truechapters}{value{chapter}}%
    % reset the number of chapters
    setcounter{appendixchapters}{0}%
    }


    begin{document}

    frontmatter

    There are total{totalchapters} total chapters.

    There are total{appendixchapters} appendix chapters.

    There are total{truechapters} true chapters.

    mainmatter

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    end{document}


    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 18 '16 at 10:12









    egreg

    708k8618813162




    708k8618813162












    • @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
      – Vladimir Parkhomenko
      Nov 24 '16 at 17:10


















    • @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
      – Vladimir Parkhomenko
      Nov 24 '16 at 17:10
















    @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
    – Vladimir Parkhomenko
    Nov 24 '16 at 17:10




    @ egreg, thank you so much! This way of problem solving is very interesting too! It uses more user-friendly names of counters. I mean especially appendixchapters instead of chapters.
    – Vladimir Parkhomenko
    Nov 24 '16 at 17:10











    6














    A variant of egreg's solution, this time using the up-to-date xassoccnt package (being the successor of assoccnt), which has a partial support for total counters.



    documentclass{memoir}
    usepackage{xassoccnt}% Version 1.2 or higher, current version is 1.7

    NewTotalDocumentCounter{appendixchapters}
    DeclareTotalAssociatedCounters{chapter}{truechapters,totalchapters}

    makeatletter
    g@addto@macroappendix{%
    SuspendCounters{truechapters}
    AddAssociatedCounters{chapter}{appendixchapters}
    }
    makeatother

    begin{document}

    frontmatter

    There are TotalValue{totalchapters} total chapters.

    There are TotalValue{appendixchapters} appendix chapters.

    There are TotalValue{truechapters} true chapters.

    mainmatter

    chapter{A}
    chapter{B}
    appendix
    chapter{C}
    chapter{D}
    chapter{E}
    chapter{F}
    chapter{G}
    chapter{H}
    chapter{I}

    end{document}


    enter image description here






    share|improve this answer




























      6














      A variant of egreg's solution, this time using the up-to-date xassoccnt package (being the successor of assoccnt), which has a partial support for total counters.



      documentclass{memoir}
      usepackage{xassoccnt}% Version 1.2 or higher, current version is 1.7

      NewTotalDocumentCounter{appendixchapters}
      DeclareTotalAssociatedCounters{chapter}{truechapters,totalchapters}

      makeatletter
      g@addto@macroappendix{%
      SuspendCounters{truechapters}
      AddAssociatedCounters{chapter}{appendixchapters}
      }
      makeatother

      begin{document}

      frontmatter

      There are TotalValue{totalchapters} total chapters.

      There are TotalValue{appendixchapters} appendix chapters.

      There are TotalValue{truechapters} true chapters.

      mainmatter

      chapter{A}
      chapter{B}
      appendix
      chapter{C}
      chapter{D}
      chapter{E}
      chapter{F}
      chapter{G}
      chapter{H}
      chapter{I}

      end{document}


      enter image description here






      share|improve this answer


























        6












        6








        6






        A variant of egreg's solution, this time using the up-to-date xassoccnt package (being the successor of assoccnt), which has a partial support for total counters.



        documentclass{memoir}
        usepackage{xassoccnt}% Version 1.2 or higher, current version is 1.7

        NewTotalDocumentCounter{appendixchapters}
        DeclareTotalAssociatedCounters{chapter}{truechapters,totalchapters}

        makeatletter
        g@addto@macroappendix{%
        SuspendCounters{truechapters}
        AddAssociatedCounters{chapter}{appendixchapters}
        }
        makeatother

        begin{document}

        frontmatter

        There are TotalValue{totalchapters} total chapters.

        There are TotalValue{appendixchapters} appendix chapters.

        There are TotalValue{truechapters} true chapters.

        mainmatter

        chapter{A}
        chapter{B}
        appendix
        chapter{C}
        chapter{D}
        chapter{E}
        chapter{F}
        chapter{G}
        chapter{H}
        chapter{I}

        end{document}


        enter image description here






        share|improve this answer














        A variant of egreg's solution, this time using the up-to-date xassoccnt package (being the successor of assoccnt), which has a partial support for total counters.



        documentclass{memoir}
        usepackage{xassoccnt}% Version 1.2 or higher, current version is 1.7

        NewTotalDocumentCounter{appendixchapters}
        DeclareTotalAssociatedCounters{chapter}{truechapters,totalchapters}

        makeatletter
        g@addto@macroappendix{%
        SuspendCounters{truechapters}
        AddAssociatedCounters{chapter}{appendixchapters}
        }
        makeatother

        begin{document}

        frontmatter

        There are TotalValue{totalchapters} total chapters.

        There are TotalValue{appendixchapters} appendix chapters.

        There are TotalValue{truechapters} true chapters.

        mainmatter

        chapter{A}
        chapter{B}
        appendix
        chapter{C}
        chapter{D}
        chapter{E}
        chapter{F}
        chapter{G}
        chapter{H}
        chapter{I}

        end{document}


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 mins ago

























        answered Mar 7 '17 at 21:55









        Christian Hupfer

        147k14192384




        147k14192384






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f339439%2fcounting-chapters-and-appendices%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

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt