Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mlreportgen.report.TableOfContents class

Package: mlreportgen.report
Superclasses:

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

Construction

toc = TableOfContents() 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.

  • HTML — A 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 using rptview, you must update the report document yourself to generate the TOC.

    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 Report Generator uses the Apache™ Formatting Objects Processor (FOP) to generate the TOC as part of PDF document generation The FOP generates the TOC in a manner similar to the way Word generates a TOC for a Word document.

toc = TableOfContents(title) creates a TOC that uses the specified title.

toc = TableOfContents(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single quotes.

Properties

expand all

Table of contents title, specified as one of these values:

  • String or character array

  • DOM object

  • 1-by-N or N-by-1 array of strings or DOM objects

  • 1-by-N or N-by-1 cell array of strings, character arrays, and/or DOM objects

  • TableOfContentsTitle reporter

Example: 'TableOfContents','Report Contents'

Layout options for this reporter, specified depending on which layout property you set. The layout properties are Watermark, FirstPageNumber, PageNumberFormat, and Landscape. See mlreportgen.report.ReporterLayout for descriptions of these properties

Source of template for this reporter, specified as one of these values:

  • String or character array specifying the path of the file containing the template for this reporter

  • Reporter or report whose template is used as the template for this reporter or whose template library contains the template for this reporter

  • DOM document or document part whose template is used as the template for this reporter or whose template library contains the template for this reporter

The specified template must be of the same type as the report to which this reporter is appended. For example, for a Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of template for this reporter, specified as a string or character array. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a string, character array that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A string or character array value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

Example: firstchapter.LinkTarget = 'ch1_link';

Methods

createTemplate Create table of contents section template
customizeReporter Create custom table of contents reporter class
getClassFolderTable of contents class definition file location
getTitleReporterGet table of contents title reporter

Inherited Methods

getImpl Get implementation of reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Default Table of Contents

Create a table of contents that uses the default formatting.

import mlreportgen.report.*
report = Report('output','pdf');
toc = TableOfContents();
add(report,toc);

Customized Table of Contents

Create a report that includes a table of contents with a title in green. This report also includes chapters, sections, and an appendix section.

import mlreportgen.report.*
import mlreportgen.dom.*

rpt = Report('Report with TOC');
add(rpt, TitlePage('Title','Report','Subtitle','with TOC'));
toc = TableOfContents;
toc.Title = Text('Table of Contents');
toc.Title.Color = 'green';
add(rpt,toc);

ch = Chapter('First Chapter');
add(ch,Section('First Subsection'));
add(ch,Section('Second Subsection'));
add(rpt,ch);
add(rpt,Chapter('Second Chapter'));

add(rpt,PDFPageLayout);
p = Paragraph('Appendix'); 
p.Style = {OutlineLevel(1), Bold, FontSize('18pt')};
add(rpt,p);

close(rpt);
rptview(rpt);

Introduced in R2017b

Was this topic helpful?