org-make-toc
This package makes it easy to one or more customizable tables of contents in Org files that can be updated manually, or automatically when the file is saved. Links to headings are created compatible with GitHub’s Org renderer.
Contents
Installation
MELPA
If you installed from MELPA, you’re done.
Manual
Install these required packages:
dashsThen put this file in your load-path, and put this in your init file:
(require 'org-make-toc)Usage
- Make a heading in the Org file where you want the table of contents, and give it the Org property
TOCwith the valuethis. - Run the command
org-make-toc.
Advanced
A document may contain multiple tables of contents. Tables of contents can be customized by setting the TOC property of headings to these values:
all: Include all headings in the file, except ignored headings.children: Include only child headings of this ToC.siblings: Include only sibling headings of this ToC.ignore: Omit a heading from the TOC.ignore-childrenor0: Omit a heading’s child headings from the TOC.- a number
N: Include child headings up toNlevels deep in the TOC.
Automatically update on save
To automatically update a file’s TOC when the file is saved, use the command add-file-local-variable to add org-make-toc to the Org file’s before-save-hook.
Or, you may activate it in all Org buffers like this:
(add-hook 'org-mode-hook #'org-make-toc-mode)Example
See example.org for a comprehensive example of the features described above.
Changelog
0.3-pre
Additions
- Option
org-make-toc-filename-prefixto add the filename before the anchor in links. This allows a ToC to refer to entries in another file by manually copying a ToC from one file into another. See issue 2. Thanks to Daniel Kraus.
Changes
- Minor refactoring.
0.2
Additions
- Multiple tables of contents are now supported in a single document.
- Entries’
TOCproperty can now also be set to the valuesall,children, andsiblings, which allow tables of contents to be created for only parts of a document.allincludes all entries in a document, including other tables of contents, except ignored entries.childrenincludes only child entries, except ignored entries.siblingsincludes only sibling entries, except ignored entries.
- The command
org-make-toc-modetogglesorg-make-tocon thebefore-save-hookin the current buffer. This may be added to the globalorg-mode-hookto activate it in every Org buffer. - The
examples.orgfile shows an example of all of the options used together in a complex, book-like document.
0.1
Initial release.
Credits
This package was inspired by Sergei Nosov’s toc-org package.
Development
Bug reports, feature requests, suggestions — oh my!
License
GPLv3