Problem statement

Beamer's 'article mode' is a wonderful vehicle for generating different documents - such as slides for presentation and handouts using LaTeX's standard 'article' class - from the same .tex source.

However, both such generated documents contain the same PDF bookmarks (i.e., the table of contents that the PDF reader shows), even though not all (sub)sections might be populated in either document. For example, some sections might not have any frames associated with them in the slides.

I am looking for a way to automatically exclude the headings of 'empty' (sub)sections from a document's PDF bookmarks.

Minimal working example (MWE)

The following MWE should be fairly self-explanatory.

  1. Put the three files below (main.tex, article.tex, beamer.tex) into the same directory.
  2. Compile the slides with a double-run of pdflatex:

    pdflatex beamer
    pdflatex beamer
  3. Compile the handout with a double-run of pdflatex:

    pdflatex article
    pdflatex article
  4. Compare the content and PDF bokmarks of article.pdf and beamer.pdf in your PDF reader.



\section{This heading appears in the PDF bookmarks of article.pdf and beamer.pdf,%
even though the section is empty in beamer.pdf}

This sentence goes into article, but not presentation mode.

\section{This heading appears in the PDF bookmarks of article.pdf and beamer.pdf,%
as it should}

 This sentence goes into both, article and presentation mode.




\usepackage{hyperref}%     Required for PDF bookmarks






% NOTE: Using this package instead of the internal PDF bookmark
% algorithm of the 'hyperref' package (which beamer uses automatically)
% does /not/ solve the problem.




Workarounds I have considered, but which don't work for me

Manually specifying the mode(s) of section headings

I believe that in Beamer's article mode, one can specify which mode(s) a section heading applies to, e.g. via

\section<presentation>{My heading}

However, due to the size of the project in question, this is not an acceptable solution for my situation. I am looking for an automated way of excluding headings of empty sections from the PDF bookmarks.

The 'bookmark' package does not solve the issue

The Beamer documentation recommends \usepackage{bookmark} over hyperref's internal PDF bookmark algorithm. I've tried this, but it does not solve the problem, as can be confirmed by uncommenting the respective line in beamer.tex above and recompiling.

closed as off-topic by user36296, TeXnician, Jagath, marsupilam, Zarko Jul 28 '17 at 18:11

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • A related question does not include any solutions to my problem. – Florian H. Jul 12 '16 at 9:17
  • There is imho no built-in way to get this behaviour. So you are actually making a feature request. Perhaps you should better move this to the beamer issue tracker. github.com/josephwright/beamer/issues – Ulrike Fischer Jul 20 '17 at 20:39
  • 4
    I'm voting to close this question as this would be better suited as a feature request – user36296 Jul 28 '17 at 16:19