1

I've created a document and added a second table of contents as per this Creating Two Separate Tables of Contents in LaTeX. However, I've just noticed that when I open the generated PDF in a PDF editor, only the Appendices section appears in the bookmarks (content pane). The rest of the sections, including the entries from the first table of contents, are missing. This issue occurs in both Google Chrome's PDF viewer and Adobe Acrobat.

Does anyone know what could be causing this?

By the way, below, I’ve included an approximate example of what I'm writing in my document for reference.

Also this is what I see in Adobe's pane: enter image description here

Thanks in advance!

Here is the code:

\documentclass{article} \usepackage{appendix} \usepackage{minitoc} \renewcommand{\partname}{} \renewcommand \thepart{} \usepackage{appendix} \usepackage{hyperref} % ========== beginning of the actual text section =========== \begin{document} \doparttoc \tableofcontents \clearpage \section{Main Section} x \clearpage \subsection{Methodology} x % In the main toc the subsubsection Experiment should not appear. However, in the document I still want to have 1.1.1 Experiment. \addtocontents{toc}{\protect\setcounter{tocdepth}{2}} \subsubsection{Experiment} x \addtocontents{toc}{\protect\setcounter{tocdepth}{3}} %reset % Start of the appendices % In the main toc I only want to see "Appendices" without its section, subsection and so on. However, in the Appendx toc (second toc) I want all section, subsection and subsubsections to appear. \addtocontents{toc}{\setcounter{tocdepth}{0}} \newpage \appendix \part{Appendices} \parttoc \clearpage \section{Appendix A} \subsection{Details of Appendix A} \subsubsection{Subsection of Appendix A} \end{document} 

Edit:

Since @cfr mentioned that the issue lies with \addtocontents{toc}{\setcounter{tocdepth}{0}}, I also wanted to point out that I wanted specific subsubsections in the main doc, such as 1.1.1 Experiment, to not appear in the main TOC. However, I still wanted them to be visible in the document itself.

Also, for sections, subsections, and subsubsections in the Appendix, I wanted them to appear in the Appendix TOC but not in the main TOC. The main TOC should only contain 'Appendices'

For the PDF viewer's bookmark pane, I wanted all sections, subsections, and subsubsections (in actual main doc and appendix) to appear.

5
  • Please note, that the three backticks for block code markdown has to be on a single line. I've corrected it this time, but you should learn how to do it correctly. If you add text after the starting marker, is would specify the language. \documentclass{article} isn't a correct language specification. A correct language specification would, e.g., be latex. But it is not needed here, because latex is the default. Commented Feb 25 at 19:36
  • Remove the second \usepackage{appendix}. Remove all auxiliary files before re-compiling (everything except the .tex file). Commented Feb 25 at 22:08
  • what are you trying to do exactly? your code compiles without error, but there are several warnings. you don't seem to actually every use any mini tocs at all, so it isn't clear why you are loading the package, but it seems to want to be loaded after hyperref. there is also a section in the manual (which the log refers you to) about precautions if used with appendix. but again, it isn't clear what you are trying to do with that package exactly either. could you say what output you expect in the document? you've set toc depth 0 globally, so you'll get minimal bookmarks. Commented Feb 26 at 1:46
  • The LaTeX code I present here is a much smaller version of my actual document. I have edited the code and added some explanations (as commetns) that I believe clarify what I wanted to achieve. However, as a side effect, no bookmarks appear in the PDF editor. btw @cfr mentioned that the issue lies with the command \addtocontents{toc}{\setcounter{tocdepth}{0}}. Commented Feb 28 at 13:50
  • you know what, it might not be the prettiest solution, but you can take your working version and just stick \addtocontents{toc}{\setcounter{tocdepth}{4}} (or change 4 to whatever depth you want) right before \end{document}... Commented Feb 28 at 14:09

1 Answer 1

1

I can tell you the source of the problem, but I can't suggest a solution because I cannot figure out what you want the code you've posted to do.

The issue has nothing to do with either minitoc or appendix, but can be reproduced with just the following code:

\documentclass{article} \usepackage{hyperref} \renewcommand{\partname}{} \renewcommand \thepart{} \begin{document} \tableofcontents \clearpage \section{Main Section} test \clearpage \subsection{Methodology} test \subsubsection{Experiment} test \addtocontents{toc}{\setcounter{tocdepth}{0}} \end{document} 

This will print

toc - 3 levels

but no bookmarks will be created so the contents panel of your PDF viewer will be empaty.

This is just a consequence of

\addtocontents{toc}{\setcounter{tocdepth}{0}} 

which is effective at the end of the document, when the bookmarks are written. Since a depth of 0 ignores everything under part and there are no parts, you get no bookmarks.

The way to avoid this is obviously not to set this counter to 0. I'm assuming you don't want sections and their sub-divisions added to the contents or bookmarks when they are part of the appendices, but you do want them included in a dedicated contents listing at the start of the appendices.

If so, the following should do what you want. It includes sections, subsections etc. in both the bookmarks and main contents, if they occur in the main part of the article. It also adds the appendices, but not its sub-divisions. However, the sub-divisions are included in a listing within the appendices part itself.

I used bookmark, which is convenient and provides nice options for bookmarks. I couldn't find a use for appendix, so I dropped that as it requires special precautions if used with minitoc. If you need it in your real document, read the relevant section of minitoc's documentation.

\documentclass{article} \usepackage[depth=3]{bookmark} \usepackage{minitoc} \renewcommand{\partname}{} \renewcommand \thepart{} \begin{document} \doparttoc \tableofcontents \clearpage \section{Main Section} test \clearpage \subsection{Methodology} test \subsubsection{Experiment} test \newpage \appendix \part{Appendices} \bookmarksetup{depth=0} \addtocontents{toc}{\setcounter{tocdepth}{0}} \parttoc \clearpage \section{Appendix A} \subsection{Details of Appendix A} \subsubsection{Subsection of Appendix A} \end{document} 

Personally, I think etoc is rather easier to use if you need localised changes to depth and structure. However, this may just be a question of familiarity, since I've never used minitoc before and it takes a rather different approach.

4
  • Thanks for the proposed solution! I just wanted to point out that I would also like the sections, subsections, and subsubsections of the Appendix to appear in the bookmark pane of the PDF viewer. What is already working and should be kept: Only 'Appendix' should appear in the main TOC. In the Appendix TOC (the second TOC), sections, subsections, and subsubsections should appear. Is this possible, or is this kind of contradictory? Commented Feb 28 at 13:49
  • By the way, I have edited my original code in the post and added a few short explanations (as comments) to clarify what I was trying to achieve. While I successfully achieved the desired result, the side effect is that I didn’t get any bookmarks in the PDF’s bookmark pane ;( Commented Feb 28 at 13:49
  • Nvm, solved it. I put \bookmarksetup{depth=0} to 2. Ty again :) Commented Mar 2 at 11:53
  • @user8059813 ah, excellent! if you wanted the same levels as for the main body, you could just delete the \bookmarksetup in the appendix. it is only there because I thought you didn't want lower level bookmarks for that part of the document. Commented Mar 2 at 20:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.