4

I want to export my .org file to pdf, with a table of contents. But I don't want the table of contents to be printed in the first page of the document. Rather I want the table of contents to be embedded in the pdf file as bookmars. For example, see the figure:

enter image description here

How do I do this?

Update:

Currently the first lines of my .org file look like this:

#+OPTIONS: num:nil
#+OPTIONS: toc:nil

If I remove the #+OPTIONS: num:nil option, I get the desired PDF index (thanks @NickD). But then the sections get automatic numbers which I want to remove.

Is there a way to get the PDF index, and also remove section numbering?

13
  • isn't this just the way your reader presents navigation in the file? which means you probably want #+OPTIONS: toc:nil Commented Sep 25, 2018 at 13:34
  • @manandearth It only works if the PDF file has the table of contents embedded. The viewer does not detect the headings automatically. But yes, I need #+OPTIONS: toc:nil to get rid of the table of contents in the first page of the document. Now I only need to get the table of contents embedded in the file. There is a way to do this in latex.
    – a06e
    Commented Sep 25, 2018 at 13:36
  • If you know how to do it in latex, perhaps you could put the right commands in a #+BEGIN_EXPORT latex block?
    – rpluim
    Commented Sep 25, 2018 at 13:55
  • @rpluim I have seen it done in LaTeX, but right now it seems cannot find the correct command. I tried #+LATEX_HEADER: \usepackage{bookmark} at the first line of my org file but nothing happens.
    – a06e
    Commented Sep 25, 2018 at 13:56
  • I thought this is handled by hyperref package: tex.stackexchange.com/questions/42343/…
    – wvxvw
    Commented Sep 25, 2018 at 16:23

2 Answers 2

4

Here is how I got it working. This produces the PDF index, no table of contents in the document, and no section numbering.

#+OPTIONS: toc:nil
#+LATEX: \setcounter{secnumdepth}{0}   

Note that I am not using #+OPTIONS: num:nil, because for some reason this option breaks the PDF index. However #+LATEX: \setcounter{secnumdepth}{0} is a workaround to prevent section numbering.

2
2

I don't think you can get rid of section numbers with num:nil and still get the index. As I explained in the chat, num:nil produces starred sections which latex treats as unnumbered sections. But then it also fails to add them to the .aux file as \contentslines, so the PDF does not get any information that can be used to generate the index.

1
  • I got it working. See my answer. Thanks for your help!
    – a06e
    Commented Sep 25, 2018 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.