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












3














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:



documentclass{book}

usepackage[nottoc,notlot,notlof]{tocbibind}
usepackage{hyperref}

begin{document}

frontmatter
tableofcontents

mainmatter
part{First}
chapter{One}
Lorem ipsum

part{Second}
chapter{Two}
Dolor sit amet

appendix

% These two commands do all the job:
addcontentsline{toc}{part}{Appendices}
part*{Appendices}

chapter{Uno}
First appendix

chapter{Due}
Secondo appendix

end{document}


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





























    3














    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:



    documentclass{book}

    usepackage[nottoc,notlot,notlof]{tocbibind}
    usepackage{hyperref}

    begin{document}

    frontmatter
    tableofcontents

    mainmatter
    part{First}
    chapter{One}
    Lorem ipsum

    part{Second}
    chapter{Two}
    Dolor sit amet

    appendix

    % These two commands do all the job:
    addcontentsline{toc}{part}{Appendices}
    part*{Appendices}

    chapter{Uno}
    First appendix

    chapter{Due}
    Secondo appendix

    end{document}


    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



























      3












      3








      3







      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:



      documentclass{book}

      usepackage[nottoc,notlot,notlof]{tocbibind}
      usepackage{hyperref}

      begin{document}

      frontmatter
      tableofcontents

      mainmatter
      part{First}
      chapter{One}
      Lorem ipsum

      part{Second}
      chapter{Two}
      Dolor sit amet

      appendix

      % These two commands do all the job:
      addcontentsline{toc}{part}{Appendices}
      part*{Appendices}

      chapter{Uno}
      First appendix

      chapter{Due}
      Secondo appendix

      end{document}


      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:



      documentclass{book}

      usepackage[nottoc,notlot,notlof]{tocbibind}
      usepackage{hyperref}

      begin{document}

      frontmatter
      tableofcontents

      mainmatter
      part{First}
      chapter{One}
      Lorem ipsum

      part{Second}
      chapter{Two}
      Dolor sit amet

      appendix

      % These two commands do all the job:
      addcontentsline{toc}{part}{Appendices}
      part*{Appendices}

      chapter{Uno}
      First appendix

      chapter{Due}
      Secondo appendix

      end{document}


      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 4 hours ago

























      asked 5 hours ago









      Taekwondavide

      37813




      37813






















          2 Answers
          2






          active

          oldest

          votes


















          3














          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



          documentclass{book}

          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          Lorem ipsum

          part{Second}
          chapter{Two}
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentsline{toc}{part}{Appendices}
          part*{Appendices}


          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            4 hours ago



















          1














          The appendix package with option [toc]works fine:



          documentclass{book}
          usepackage{lipsum}
          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage[toc]{appendix}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          lipsum
          part{Second}
          chapter{Two}

          lipsum

          appendix
          appendixpage

          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago











          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









          3














          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



          documentclass{book}

          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          Lorem ipsum

          part{Second}
          chapter{Two}
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentsline{toc}{part}{Appendices}
          part*{Appendices}


          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            4 hours ago
















          3














          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



          documentclass{book}

          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          Lorem ipsum

          part{Second}
          chapter{Two}
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentsline{toc}{part}{Appendices}
          part*{Appendices}


          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            4 hours ago














          3












          3








          3






          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



          documentclass{book}

          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          Lorem ipsum

          part{Second}
          chapter{Two}
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentsline{toc}{part}{Appendices}
          part*{Appendices}


          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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



          documentclass{book}

          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          Lorem ipsum

          part{Second}
          chapter{Two}
          Dolor sit amet

          appendix

          % These two commands do all the job:

          cleardoublepage
          phantomsection
          addcontentsline{toc}{part}{Appendices}
          part*{Appendices}


          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 4 hours ago









          samcarter

          85.5k794273




          85.5k794273












          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            4 hours ago






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            4 hours ago


















          • A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
            – Taekwondavide
            4 hours ago






          • 1




            @Taekwondavide You're welcome!
            – samcarter
            4 hours ago
















          A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
          – Taekwondavide
          4 hours ago




          A very clean and simple solution, that's exactly what I was looking for, thank you! It also works with bookmark package.
          – Taekwondavide
          4 hours ago




          1




          1




          @Taekwondavide You're welcome!
          – samcarter
          4 hours ago




          @Taekwondavide You're welcome!
          – samcarter
          4 hours ago











          1














          The appendix package with option [toc]works fine:



          documentclass{book}
          usepackage{lipsum}
          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage[toc]{appendix}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          lipsum
          part{Second}
          chapter{Two}

          lipsum

          appendix
          appendixpage

          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago
















          1














          The appendix package with option [toc]works fine:



          documentclass{book}
          usepackage{lipsum}
          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage[toc]{appendix}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          lipsum
          part{Second}
          chapter{Two}

          lipsum

          appendix
          appendixpage

          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          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
            4 hours ago














          1












          1








          1






          The appendix package with option [toc]works fine:



          documentclass{book}
          usepackage{lipsum}
          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage[toc]{appendix}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          lipsum
          part{Second}
          chapter{Two}

          lipsum

          appendix
          appendixpage

          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          enter image description here






          share|improve this answer












          The appendix package with option [toc]works fine:



          documentclass{book}
          usepackage{lipsum}
          usepackage[nottoc,notlot,notlof]{tocbibind}
          usepackage[toc]{appendix}
          usepackage{hyperref}

          begin{document}

          frontmatter
          tableofcontents

          mainmatter
          part{First}
          chapter{One}
          lipsum
          part{Second}
          chapter{Two}

          lipsum

          appendix
          appendixpage

          chapter{Uno}
          First appendix

          chapter{Due}
          Secondo appendix

          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 4 hours ago









          Bernard

          165k769193




          165k769193












          • 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
            4 hours ago


















          • 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
            4 hours ago
















          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
          4 hours ago




          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
          4 hours ago


















          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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'