emacsorg-mode

Howto Generate TOC in Org Mode Documents


For Org Mode, I'm trying to generate a Table of Contents, but can't seem to make any headway. I've looked at the official documentation. Although I suspect this is just for exporting Org documents.

I've not found any direction on how to actually generate a Table of Contents with links that would appear in Github. I've also explored snosov1/toc-org and alphapapa/org-make-toc. But their functions don't even generate malformed TOCs.

I was able to generate a TOC once with alphapapa/org-make-toc. But can't replicate the result when trying to generate. Sometimes nothing happens. And sometimes running org-make-toc throws the message: user-error: Before first headline at position 213 in buffer SUNRA.org (source). What am I missing?

Emacs: 29.4 (https://emacsformacosx.com)


Solution

  • There seem to be two things wrong with the SUNRA.org file you are using:

    In short, the Table of Contents headline should start like this:

    ...
    * Table of Contents
    :PROPERTIES:
    :TOC:      :include all :ignore this
    :END:
    :CONTENTS:
    
    :END:
    ...