Skip to content

(enhancement) double proposal for the TOC #1612

@ousia

Description

@ousia

The proposal for both TOC title and placement can be simplified without the need of any YAML metadata field.

@ryangray proposed this before, but I didn’t get his proposal then (Ryan, my apologies for not having understood your proposal, which was simpler and better).

All it is required is reserving unique identifier names for sections with automatically–generated contents. In this case it would be {#toc}.

Titles would be included in headings themselves:

# Contents {#toc}

# Inhalt {#toc}

# Περιεχόμενα {#toc}

This way they could also be placed where the user wants.

The same logic could be applied for references (reserving identifier {#references}) and footnotes (reserving name {#footnotes}).

I append the original proposal as a comment for historical purposes.

As already discussed in the mailing list, it would be useful for the users to change the title of the TOC and the place the TOC wherever they want in their document.

My double proposal would be the following:

  1. Add a field named toc in the YAML metadata.

    Title should be specified as:

    toc: The Contents
    

    If the field is empty (or contains only spaces), TOC title should be removed.

    The default option remains the same, if there is no toc field in the YAML metadata.

    This hard codes the title, but it is the user who does it and for each document.

  2. Allow different placement from its default location.

    The easiest way would be to add a first-level title, such as in:

    # tableofcontents
    
  3. Both options should be independent from each other.

    Any of these previous options enables internally the --toc option in pandoc.

Could these suggestions be implemented in pandoc?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions