A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4














I found a lot of questions abount appendices and ToC. Many users want appendices to be grouped in an Appendix part, however some problems arise with ToC, hyperref, PDF viewer bookmarks, and so on.



There are different solutions which require extra packages, command patching and other extra code, however none of them satisfies me. I almost found an easy way to accomplish a good result, where appendices are added to bookmarks in the right way and hyperref links point to the right page. However, the number of the "Appendix" part page is wrong (it's the number of appendix A). Is there any EASY way to fix that?



This is a MWE:



documentclassbook

usepackage[nottoc,notlot,notlof]tocbibind
usepackagehyperref

begindocument

frontmatter
tableofcontents

mainmatter
partFirst
chapterOne
Lorem ipsum

partSecond
chapterTwo
Dolor sit amet

appendix

% These two commands do all the job:
addcontentslinetocpartAppendices
part*Appendices

chapterUno
First appendix

chapterDue
Secondo appendix

enddocument


This is the ToC (with links pointing to the right page)



I First 1
1 One 3

II Second 5
2 Two 7

Appendices 11 (this should be 9)
A Uno 11
B Due 13


Using bookmark package instead of (in addition to) hyperref make it worse (Appendix link and ToC page will point to chapter "Two"). Switching addcontentsline and part* doesn't solve the problem.



EDIT: for some reasons, I do not want to use appendix package










share|improve this question




























    4














    I found a lot of questions abount appendices and ToC. Many users want appendices to be grouped in an Appendix part, however some problems arise with ToC, hyperref, PDF viewer bookmarks, and so on.



    There are different solutions which require extra packages, command patching and other extra code, however none of them satisfies me. I almost found an easy way to accomplish a good result, where appendices are added to bookmarks in the right way and hyperref links point to the right page. However, the number of the "Appendix" part page is wrong (it's the number of appendix A). Is there any EASY way to fix that?



    This is a MWE:



    documentclassbook

    usepackage[nottoc,notlot,notlof]tocbibind
    usepackagehyperref

    begindocument

    frontmatter
    tableofcontents

    mainmatter
    partFirst
    chapterOne
    Lorem ipsum

    partSecond
    chapterTwo
    Dolor sit amet

    appendix

    % These two commands do all the job:
    addcontentslinetocpartAppendices
    part*Appendices

    chapterUno
    First appendix

    chapterDue
    Secondo appendix

    enddocument


    This is the ToC (with links pointing to the right page)



    I First 1
    1 One 3

    II Second 5
    2 Two 7

    Appendices 11 (this should be 9)
    A Uno 11
    B Due 13


    Using bookmark package instead of (in addition to) hyperref make it worse (Appendix link and ToC page will point to chapter "Two"). Switching addcontentsline and part* doesn't solve the problem.



    EDIT: for some reasons, I do not want to use appendix package










    share|improve this question


























      4












      4








      4







      I found a lot of questions abount appendices and ToC. Many users want appendices to be grouped in an Appendix part, however some problems arise with ToC, hyperref, PDF viewer bookmarks, and so on.



      There are different solutions which require extra packages, command patching and other extra code, however none of them satisfies me. I almost found an easy way to accomplish a good result, where appendices are added to bookmarks in the right way and hyperref links point to the right page. However, the number of the "Appendix" part page is wrong (it's the number of appendix A). Is there any EASY way to fix that?



      This is a MWE:



      documentclassbook

      usepackage[nottoc,notlot,notlof]tocbibind
      usepackagehyperref

      begindocument

      frontmatter
      tableofcontents

      mainmatter
      partFirst
      chapterOne
      Lorem ipsum

      partSecond
      chapterTwo
      Dolor sit amet

      appendix

      % These two commands do all the job:
      addcontentslinetocpartAppendices
      part*Appendices

      chapterUno
      First appendix

      chapterDue
      Secondo appendix

      enddocument


      This is the ToC (with links pointing to the right page)



      I First 1
      1 One 3

      II Second 5
      2 Two 7

      Appendices 11 (this should be 9)
      A Uno 11
      B Due 13


      Using bookmark package instead of (in addition to) hyperref make it worse (Appendix link and ToC page will point to chapter "Two"). Switching addcontentsline and part* doesn't solve the problem.



      EDIT: for some reasons, I do not want to use appendix package










      share|improve this question















      I found a lot of questions abount appendices and ToC. Many users want appendices to be grouped in an Appendix part, however some problems arise with ToC, hyperref, PDF viewer bookmarks, and so on.



      There are different solutions which require extra packages, command patching and other extra code, however none of them satisfies me. I almost found an easy way to accomplish a good result, where appendices are added to bookmarks in the right way and hyperref links point to the right page. However, the number of the "Appendix" part page is wrong (it's the number of appendix A). Is there any EASY way to fix that?



      This is a MWE:



      documentclassbook

      usepackage[nottoc,notlot,notlof]tocbibind
      usepackagehyperref

      begindocument

      frontmatter
      tableofcontents

      mainmatter
      partFirst
      chapterOne
      Lorem ipsum

      partSecond
      chapterTwo
      Dolor sit amet

      appendix

      % These two commands do all the job:
      addcontentslinetocpartAppendices
      part*Appendices

      chapterUno
      First appendix

      chapterDue
      Secondo appendix

      enddocument


      This is the ToC (with links pointing to the right page)



      I First 1
      1 One 3

      II Second 5
      2 Two 7

      Appendices 11 (this should be 9)
      A Uno 11
      B Due 13


      Using bookmark package instead of (in addition to) hyperref make it worse (Appendix link and ToC page will point to chapter "Two"). Switching addcontentsline and part* doesn't solve the problem.



      EDIT: for some reasons, I do not want to use appendix package







      table-of-contents hyperref appendices






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 26 '18 at 23:22







      Taekwondavide

















      asked Dec 26 '18 at 23:15









      TaekwondavideTaekwondavide

      38313




      38313




















          2 Answers
          2






          active

          oldest

          votes


















          4














          You can provide a suitable target for the hyperlink by introducing a phantomsection. To ensure that this link to the correct page, use if after cleardoubelpage



          documentclassbook

          usepackage[nottoc,notlot,notlof]tocbibind
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          Lorem ipsum

          partSecond
          chapterTwo
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentslinetocpartAppendices
          part*Appendices


          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            Dec 26 '18 at 23:40






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            Dec 26 '18 at 23:41


















          3














          The appendix package with option [toc]works fine:



          documentclassbook
          usepackagelipsum
          usepackage[nottoc,notlot,notlof]tocbibind
          usepackage[toc]appendix
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          lipsum
          partSecond
          chapterTwo

          lipsum

          appendix
          appendixpage

          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
            – Taekwondavide
            Dec 26 '18 at 23:52










          • @Taekwondavide Have you contacted the appendix package maintainer about this?
            – Peter Wilson
            Dec 27 '18 at 20:23










          • @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
            – Taekwondavide
            Dec 28 '18 at 2:52











          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%2f467460%2fa-clean-and-simple-way-to-add-appendices-to-table-of-contents-and-bookmarks%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









          4














          You can provide a suitable target for the hyperlink by introducing a phantomsection. To ensure that this link to the correct page, use if after cleardoubelpage



          documentclassbook

          usepackage[nottoc,notlot,notlof]tocbibind
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          Lorem ipsum

          partSecond
          chapterTwo
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentslinetocpartAppendices
          part*Appendices


          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            Dec 26 '18 at 23:40






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            Dec 26 '18 at 23:41















          4














          You can provide a suitable target for the hyperlink by introducing a phantomsection. To ensure that this link to the correct page, use if after cleardoubelpage



          documentclassbook

          usepackage[nottoc,notlot,notlof]tocbibind
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          Lorem ipsum

          partSecond
          chapterTwo
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentslinetocpartAppendices
          part*Appendices


          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            Dec 26 '18 at 23:40






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            Dec 26 '18 at 23:41













          4












          4








          4






          You can provide a suitable target for the hyperlink by introducing a phantomsection. To ensure that this link to the correct page, use if after cleardoubelpage



          documentclassbook

          usepackage[nottoc,notlot,notlof]tocbibind
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          Lorem ipsum

          partSecond
          chapterTwo
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentslinetocpartAppendices
          part*Appendices


          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer












          You can provide a suitable target for the hyperlink by introducing a phantomsection. To ensure that this link to the correct page, use if after cleardoubelpage



          documentclassbook

          usepackage[nottoc,notlot,notlof]tocbibind
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          Lorem ipsum

          partSecond
          chapterTwo
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentslinetocpartAppendices
          part*Appendices


          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 26 '18 at 23:27









          samcartersamcarter

          86.4k795276




          86.4k795276











          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            Dec 26 '18 at 23:40






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            Dec 26 '18 at 23:41
















          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            Dec 26 '18 at 23:40






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            Dec 26 '18 at 23:41















          A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
          – Taekwondavide
          Dec 26 '18 at 23:40




          A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
          – Taekwondavide
          Dec 26 '18 at 23:40




          1




          1




          @Taekwondavide You're welcome!
          – samcarter
          Dec 26 '18 at 23:41




          @Taekwondavide You're welcome!
          – samcarter
          Dec 26 '18 at 23:41











          3














          The appendix package with option [toc]works fine:



          documentclassbook
          usepackagelipsum
          usepackage[nottoc,notlot,notlof]tocbibind
          usepackage[toc]appendix
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          lipsum
          partSecond
          chapterTwo

          lipsum

          appendix
          appendixpage

          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
            – Taekwondavide
            Dec 26 '18 at 23:52










          • @Taekwondavide Have you contacted the appendix package maintainer about this?
            – Peter Wilson
            Dec 27 '18 at 20:23










          • @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
            – Taekwondavide
            Dec 28 '18 at 2:52
















          3














          The appendix package with option [toc]works fine:



          documentclassbook
          usepackagelipsum
          usepackage[nottoc,notlot,notlof]tocbibind
          usepackage[toc]appendix
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          lipsum
          partSecond
          chapterTwo

          lipsum

          appendix
          appendixpage

          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer




















          • Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
            – Taekwondavide
            Dec 26 '18 at 23:52










          • @Taekwondavide Have you contacted the appendix package maintainer about this?
            – Peter Wilson
            Dec 27 '18 at 20:23










          • @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
            – Taekwondavide
            Dec 28 '18 at 2:52














          3












          3








          3






          The appendix package with option [toc]works fine:



          documentclassbook
          usepackagelipsum
          usepackage[nottoc,notlot,notlof]tocbibind
          usepackage[toc]appendix
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          lipsum
          partSecond
          chapterTwo

          lipsum

          appendix
          appendixpage

          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here






          share|improve this answer












          The appendix package with option [toc]works fine:



          documentclassbook
          usepackagelipsum
          usepackage[nottoc,notlot,notlof]tocbibind
          usepackage[toc]appendix
          usepackagehyperref

          begindocument

          frontmatter
          tableofcontents

          mainmatter
          partFirst
          chapterOne
          lipsum
          partSecond
          chapterTwo

          lipsum

          appendix
          appendixpage

          chapterUno
          First appendix

          chapterDue
          Secondo appendix

          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 26 '18 at 23:39









          BernardBernard

          166k769194




          166k769194











          • Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
            – Taekwondavide
            Dec 26 '18 at 23:52










          • @Taekwondavide Have you contacted the appendix package maintainer about this?
            – Peter Wilson
            Dec 27 '18 at 20:23










          • @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
            – Taekwondavide
            Dec 28 '18 at 2:52

















          • Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
            – Taekwondavide
            Dec 26 '18 at 23:52










          • @Taekwondavide Have you contacted the appendix package maintainer about this?
            – Peter Wilson
            Dec 27 '18 at 20:23










          • @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
            – Taekwondavide
            Dec 28 '18 at 2:52
















          Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
          – Taekwondavide
          Dec 26 '18 at 23:52




          Thank you, I already knew this package, however for some reasons (such as the fact that it messes up TeXstudio structure tree) I prefer not to use it. Also, I was looking for a more general solution that may apply to other situations too (not only the appendix).
          – Taekwondavide
          Dec 26 '18 at 23:52












          @Taekwondavide Have you contacted the appendix package maintainer about this?
          – Peter Wilson
          Dec 27 '18 at 20:23




          @Taekwondavide Have you contacted the appendix package maintainer about this?
          – Peter Wilson
          Dec 27 '18 at 20:23












          @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
          – Taekwondavide
          Dec 28 '18 at 2:52





          @PeterWilson I badly explained myself. Appendix package works fine, but TeXstudio doesn't recognize appendixpage as a new part of the document, which causes all appendices to be seen seen by the editor as chapters of the last part in the main matter, which is quite annoying for me as I'm using TeXstudio's structure tree a lot (this is not the only reason I want to fix my code without additional packages). However, the bookmark tree in PDF viewer is correct and appendices are seen as a part.
          – Taekwondavide
          Dec 28 '18 at 2:52


















          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%2f467460%2fa-clean-and-simple-way-to-add-appendices-to-table-of-contents-and-bookmarks%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

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)