Skip to content

Markdown2Pdf.Options.TableOfContentsOptions

GitHub Action edited this page Mar 24, 2025 · 6 revisions

Class TableOfContentsOptions

Namespace: Markdown2Pdf.Options
Assembly: Markdown2Pdf.dll

Options to create a Table of Contents for the PDF, generated from all headers. The TOC will be inserted into all [TOC], [[TOC]] or <!-- toc --> comments within the markdown document.
Example Markdown document with a TOC:

# My Document
[TOC]
...
Example creating a TOC:
options.TableOfContents = new TableOfContentsOptions {
ListStyle = ListStyle.Decimal,

// Include all heading levels from 2 to 4.
MinDepthLevel = 2,
MaxDepthLevel = 4
};
A header can be omitted from the toc by ending it with <!-- omit from toc -->:
## This header won't be displayed in the TOC &lt;!-- omit from toc --&gt;
public class TableOfContentsOptions

Inheritance

objectTableOfContentsOptions

Inherited Members

object.Equals(object), object.Equals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object, object), object.ToString()

Remarks

The TOC gets generated within a <nav class="table-of-contents">. This can be used to apply extra custom styles.

Properties

HasColoredLinks

Determines if the TOC links should have the default link color (instead of looking like normal text). Default: false.

public bool HasColoredLinks { get; set; }

Property Value

bool

ListStyle

Decides which characters to use before the TOC items.

public ListStyle ListStyle { get; set; }

Property Value

ListStyle

MaxDepthLevel

The maximum level of heading depth to include in the TOC (e.g. 3 will include headings less than or equal to <h3>). Range: 1 to 6. Default: 6.

public int MaxDepthLevel { get; set; }

Property Value

int

MinDepthLevel

The minimum level of heading depth to include in the TOC (e.g. 1 will only include headings greater than or equal to <h1>). Range: 1 to 6. Default: 1.

public int MinDepthLevel { get; set; }

Property Value

int

PageNumberOptions

If set, the TOC will be generated with page numbers. Default: null.

public PageNumberOptions? PageNumberOptions { get; set; }

Property Value

PageNumberOptions?

Remarks

This causes the PDF to be generated twice to calculate the page numbers.

Clone this wiki locally