mlreportgen.report.TableOfContents Class
Namespace: mlreportgen.report
Superclasses: mlreportgen.report.Reporter
Table of contents reporter
Description
Create a table of contents (TOC) reporter that adds a table of contents to the report.
This class inherits from mlreportgen.report.Reporter
.
The mlreportgen.report.TableOfContents
class is a handle
class.
Creation
Description
returns a
reporter that generates a table of contents (TOC) section for the report.
The default template for the TOC section defines the appearance and page
layout of the TOC. The TOC section contains a default title and a TOC
element that specifies the location of a TOC to be generated, depending on
the report output type. The way in which the TOC is generated differs for
each report type. toc
= TableOfContents
HTML — JavaScript® copied from the report template to the report generates the TOC when the report is opened in a browser. The script generates the TOC as a collapsible tree. The tree entries are the hyperlinked contents of the HTML heading elements (h1-h6) of the report. The level of an entry in the TOC tree corresponds to the level of the heading element. Chapter and section reporters generate chapter and section titles as heading elements of the appropriate level, so chapter and section titles appear automatically in the TOC. You can also use DOM Heading elements in a report to generate TOC entries.
DOCX — The Report Generator
rptview
function instructs Word to generate the TOC after it opens the report in Word. If you open a report in Word directly, without usingrptview
, you must update the report document yourself to generate the TOC. See Update Tables of Contents and Generated Lists in Word Documents.The TOC is a two-column table. The first column contains the hyperlinked contents of report paragraphs whose outline levels have been set. The outline level determines the formatting of a TOC entry. The second column contains the number of the page on which the corresponding paragraph occurs. Chapter and section reporters generate chapter and section titles as paragraphs with the appropriate level set, so chapter and section titles appear automatically in the TOC. You can also use DOM Heading elements in a report to generate TOC entries.
PDF — The table of contents is generated during PDF document generation.
creates a TOC that uses the specified toc
= TableOfContents(title
)title
.
sets properties using name-value arguments. You can specify multiple name-value arguments in any order.toc
= TableOfContents(Name=Value
)
Properties
Methods
Examples
Tips
The report template determines the size, spacing, color, and other format properties
of the TOC generated by this reporter. The default Microsoft Word and PDF templates contain default styles for each entry in the TOC. To
change the format of your TOC, create a custom report template that redefines these
styles and use the template when you generate your report. See mlreportgen.report.Report.createTemplate
. The styles are named
TOC1
, TOC2
, …, TOC6
, where
style TOC1
defines the format of level 1 entries, style
TOC2
defines the format of level 2 entries, etc.