Is there a possibility to make the `ref` command return `part` numbers in addition to `chapter`, `section` and `subsection` numbering?









up vote
6
down vote

favorite












As a default documentclass book numbers chapters consecutively regardless of the division into parts, and I suppose the ref command had been designed with this in mind, returning as it does chapter, section and subsection numbering. The clause @addtoresetchapterpart will cause chapters to be numbered starting with 1 for each part. Is there a way of paramatrizing ref to return part numbers?



documentclassbook
% RN. 10 Nov 2018
%=======================
%usepackagehyperref
makeatletter
@addtoresetchapterpart
makeatother
begindocument
chapter*Preface
Referencing both sections produce identical numbering. It would be helpful to distinguish parts:\
refA1, page pagerefA1\
refB1, page pagerefB1\
partFIRST
chapterA
sectionA1labelA1
partSECOND
chapterB
sectionB1labelB1
enddocument









share|improve this question



















  • 4




    Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
    – moewe
    Nov 10 at 7:33










  • Works like a charm. How do I mark this as the answer?
    – Reinhard Neuwirth
    Nov 10 at 9:01






  • 1




    You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
    – David Carlisle
    Nov 10 at 9:07










  • To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
    – Reinhard Neuwirth
    Nov 10 at 9:27














up vote
6
down vote

favorite












As a default documentclass book numbers chapters consecutively regardless of the division into parts, and I suppose the ref command had been designed with this in mind, returning as it does chapter, section and subsection numbering. The clause @addtoresetchapterpart will cause chapters to be numbered starting with 1 for each part. Is there a way of paramatrizing ref to return part numbers?



documentclassbook
% RN. 10 Nov 2018
%=======================
%usepackagehyperref
makeatletter
@addtoresetchapterpart
makeatother
begindocument
chapter*Preface
Referencing both sections produce identical numbering. It would be helpful to distinguish parts:\
refA1, page pagerefA1\
refB1, page pagerefB1\
partFIRST
chapterA
sectionA1labelA1
partSECOND
chapterB
sectionB1labelB1
enddocument









share|improve this question



















  • 4




    Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
    – moewe
    Nov 10 at 7:33










  • Works like a charm. How do I mark this as the answer?
    – Reinhard Neuwirth
    Nov 10 at 9:01






  • 1




    You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
    – David Carlisle
    Nov 10 at 9:07










  • To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
    – Reinhard Neuwirth
    Nov 10 at 9:27












up vote
6
down vote

favorite









up vote
6
down vote

favorite











As a default documentclass book numbers chapters consecutively regardless of the division into parts, and I suppose the ref command had been designed with this in mind, returning as it does chapter, section and subsection numbering. The clause @addtoresetchapterpart will cause chapters to be numbered starting with 1 for each part. Is there a way of paramatrizing ref to return part numbers?



documentclassbook
% RN. 10 Nov 2018
%=======================
%usepackagehyperref
makeatletter
@addtoresetchapterpart
makeatother
begindocument
chapter*Preface
Referencing both sections produce identical numbering. It would be helpful to distinguish parts:\
refA1, page pagerefA1\
refB1, page pagerefB1\
partFIRST
chapterA
sectionA1labelA1
partSECOND
chapterB
sectionB1labelB1
enddocument









share|improve this question















As a default documentclass book numbers chapters consecutively regardless of the division into parts, and I suppose the ref command had been designed with this in mind, returning as it does chapter, section and subsection numbering. The clause @addtoresetchapterpart will cause chapters to be numbered starting with 1 for each part. Is there a way of paramatrizing ref to return part numbers?



documentclassbook
% RN. 10 Nov 2018
%=======================
%usepackagehyperref
makeatletter
@addtoresetchapterpart
makeatother
begindocument
chapter*Preface
Referencing both sections produce identical numbering. It would be helpful to distinguish parts:\
refA1, page pagerefA1\
refB1, page pagerefB1\
partFIRST
chapterA
sectionA1labelA1
partSECOND
chapterB
sectionB1labelB1
enddocument






cross-referencing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 7:36









moewe

84.1k9107322




84.1k9107322










asked Nov 10 at 7:32









Reinhard Neuwirth

1,49511322




1,49511322







  • 4




    Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
    – moewe
    Nov 10 at 7:33










  • Works like a charm. How do I mark this as the answer?
    – Reinhard Neuwirth
    Nov 10 at 9:01






  • 1




    You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
    – David Carlisle
    Nov 10 at 9:07










  • To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
    – Reinhard Neuwirth
    Nov 10 at 9:27












  • 4




    Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
    – moewe
    Nov 10 at 7:33










  • Works like a charm. How do I mark this as the answer?
    – Reinhard Neuwirth
    Nov 10 at 9:01






  • 1




    You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
    – David Carlisle
    Nov 10 at 9:07










  • To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
    – Reinhard Neuwirth
    Nov 10 at 9:27







4




4




Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
– moewe
Nov 10 at 7:33




Something like renewcommand*p@sectionthepart. (within makeatletter...makeatother)?
– moewe
Nov 10 at 7:33












Works like a charm. How do I mark this as the answer?
– Reinhard Neuwirth
Nov 10 at 9:01




Works like a charm. How do I mark this as the answer?
– Reinhard Neuwirth
Nov 10 at 9:01




1




1




You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
– David Carlisle
Nov 10 at 9:07




You need to ping @moewe and ask that the text be re-posted as an answer, you can't mark comments as accepted answers.
– David Carlisle
Nov 10 at 9:07












To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
– Reinhard Neuwirth
Nov 10 at 9:27




To complete @moewe 's answer I now use renewcommand*p@chapterthepart., renewcommand*p@sectionthepart. and renewcommand*p@subsectionthepart., sandwiched beween makeatletter and makeatother, and have ref return numbering for all `part/chapter/section/subsection' as required. Please repost your comment as an answer so I can tick it off.
– Reinhard Neuwirth
Nov 10 at 9:27










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










You can redefine p@<counter> to modify the output of ref without changing the actual representation of <counter> elsewhere. You might try something like renewcommand*p@sectionthepart. or similar.



documentclassbook

makeatletter
@addtoresetchapterpart
renewcommand*p@chapterthepart.
renewcommand*p@sectionthepart.
renewcommand*p@subsectionthepart.
makeatother

begindocument
chapter*Preface
Referencing both sections produce identical numbering. It would be helpful to distinguish parts:

refA1, page pagerefA1

refB1, page pagerefB1

partFIRST
chapterA
sectionA1labelA1

partSECOND
chapterB
sectionB1labelB1
enddocument


the <code>ref</code>s produce "I.1.1, page 5" and "II.1.1, page 9"






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',
    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%2f459272%2fis-there-a-possibility-to-make-the-ref-command-return-part-numbers-in-addi%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    You can redefine p@<counter> to modify the output of ref without changing the actual representation of <counter> elsewhere. You might try something like renewcommand*p@sectionthepart. or similar.



    documentclassbook

    makeatletter
    @addtoresetchapterpart
    renewcommand*p@chapterthepart.
    renewcommand*p@sectionthepart.
    renewcommand*p@subsectionthepart.
    makeatother

    begindocument
    chapter*Preface
    Referencing both sections produce identical numbering. It would be helpful to distinguish parts:

    refA1, page pagerefA1

    refB1, page pagerefB1

    partFIRST
    chapterA
    sectionA1labelA1

    partSECOND
    chapterB
    sectionB1labelB1
    enddocument


    the <code>ref</code>s produce "I.1.1, page 5" and "II.1.1, page 9"






    share|improve this answer
























      up vote
      6
      down vote



      accepted










      You can redefine p@<counter> to modify the output of ref without changing the actual representation of <counter> elsewhere. You might try something like renewcommand*p@sectionthepart. or similar.



      documentclassbook

      makeatletter
      @addtoresetchapterpart
      renewcommand*p@chapterthepart.
      renewcommand*p@sectionthepart.
      renewcommand*p@subsectionthepart.
      makeatother

      begindocument
      chapter*Preface
      Referencing both sections produce identical numbering. It would be helpful to distinguish parts:

      refA1, page pagerefA1

      refB1, page pagerefB1

      partFIRST
      chapterA
      sectionA1labelA1

      partSECOND
      chapterB
      sectionB1labelB1
      enddocument


      the <code>ref</code>s produce "I.1.1, page 5" and "II.1.1, page 9"






      share|improve this answer






















        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        You can redefine p@<counter> to modify the output of ref without changing the actual representation of <counter> elsewhere. You might try something like renewcommand*p@sectionthepart. or similar.



        documentclassbook

        makeatletter
        @addtoresetchapterpart
        renewcommand*p@chapterthepart.
        renewcommand*p@sectionthepart.
        renewcommand*p@subsectionthepart.
        makeatother

        begindocument
        chapter*Preface
        Referencing both sections produce identical numbering. It would be helpful to distinguish parts:

        refA1, page pagerefA1

        refB1, page pagerefB1

        partFIRST
        chapterA
        sectionA1labelA1

        partSECOND
        chapterB
        sectionB1labelB1
        enddocument


        the <code>ref</code>s produce "I.1.1, page 5" and "II.1.1, page 9"






        share|improve this answer












        You can redefine p@<counter> to modify the output of ref without changing the actual representation of <counter> elsewhere. You might try something like renewcommand*p@sectionthepart. or similar.



        documentclassbook

        makeatletter
        @addtoresetchapterpart
        renewcommand*p@chapterthepart.
        renewcommand*p@sectionthepart.
        renewcommand*p@subsectionthepart.
        makeatother

        begindocument
        chapter*Preface
        Referencing both sections produce identical numbering. It would be helpful to distinguish parts:

        refA1, page pagerefA1

        refB1, page pagerefB1

        partFIRST
        chapterA
        sectionA1labelA1

        partSECOND
        chapterB
        sectionB1labelB1
        enddocument


        the <code>ref</code>s produce "I.1.1, page 5" and "II.1.1, page 9"







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 10:59









        moewe

        84.1k9107322




        84.1k9107322



























            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%2f459272%2fis-there-a-possibility-to-make-the-ref-command-return-part-numbers-in-addi%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

            Use pre created SQLite database for Android project in kotlin

            Darth Vader #20

            Ondo