mlreportgen.report.Chapter Class
Namespace: mlreportgen.report
Superclasses: mlreportgen.report.Section
Chapter reporter
Description
Use an object of the mlreportgen.report.Chapter
class to add a chapter
to a report.
The mlreportgen.report.Chapter
class is a handle
class.
Creation
Description
creates a reporter that generates a chapter. The chapter has a new page layout
defined by the default template of the reporter. ch
= mlreportgen.report.Chapter
The default template is a portrait page with a header and a footer. The header is empty. If a chapter is the first chapter of the report, the footer contains an automatically generated page number that starts with 1. If the chapter is not the first chapter, the page numbering continues from the last page of the previous chapter. Use the Layout property to override some of the page layout features of the chapter, such as the orientation.
Use the Title property to specify the title.
To add content to the chapter, use the append
method of the
mlreportgen.report.Chapter
object.
Note
Before you add a chapter to a report, add all of the content to the chapter. Once you add the chapter to a report, you cannot add more content to the chapter.
creates a chapter with the specified title. See the Title property.ch
= mlreportgen.report.Chapter(title
)
sets properties using name-value pairs. You can specify multiple name-value pair
arguments in any order.ch
= mlreportgen.report.Chapter(Name=Value
)
Properties
Title
— Chapter title
character vector | string scalar | DOM element object | getTitleReporter
reporter | ...
Chapter title, specified as one of these values:
String scalar or character vector
DOM element object
1-by-N or N-by-1 array of string scalars or DOM element objects
1-by-N or N-by-1 cell array of string scalars, character vectors, and/or DOM element objects
SectionTitle
reporter returned by thegetTitleReporter
method
The title appears at the beginning of the chapter and in the header of all chapter pages except the first page. The title also appears in the table of contents of the report.
Inline objects are objects that a paragraph can contain. If the title
value is an inline object, the Chapter
object uses a template
from its template library to create a title based on the value. The template
used to create the title depends on whether the title is numbered. A chapter
title is numbered by default. To turn off numbering for this chapter, use
the Numbered
property. To turn off numbering for all
other chapters in the report, use the
mlreportgen.report.Section.number
method.
If the title is numbered, the title is prefixed in English reports by a
string of the form Chapter N, where N
is the automatically generated chapter number. In some other locales, the
English prefix is translated to the language of the locale. See the
Locale
property of
mlreportgen.report.Report
for a list of translated
locales.
You can use inline DOM element objects to override the character formatting specified by the chapter default title templates.
If the title value is a DOM paragraph or other DOM block object, the chapter inserts the object at the beginning of the chapter. If you use a DOM block object, you can use block elements to customize the spacing, alignment, and other properties of the chapter title. In this case, you must fully specify the title format and provide title numbering yourself.
Note
For the page headers to correctly display the title, the style name of
the title must be SectionTitle1
. If the title is
specified as a DOM mlreportgen.dom.Paragraph
object with
no StyleName
set, the StyleName
property is automatically changed to the correct style name. You can
customize the paragraph style by including DOM style objects in the
Style
property of the Paragraph
object. If you use a custom template to format the title, make sure the
style name used by the template is SectionTitle1
.
Customize the title style by modifying the
SectionTitle1
style in the custom
template.
Numbered
— Whether to number this chapter
[]
(default) | true
| false
Whether to number this chapter, specified as true
or
false
. If the value of Numbered
is empty or true
, the chapter is numbered relative to
other chapters in the report. The chapter number appears in the title. If
the value of Numbered
is false
, this
chapter is not numbered. The value of the Numbered
property overrides the numbering specified for all report chapters by the
mlreportgen.report.Chapter.number
method.
Data Types: logical
Content
— Content of this section
character vector | string scalar | inline object | ...
Content of the section, specified as one of these values:
String scalar or character vector
DOM element objects that can be added to a DOM document part
Reporters, including
Section
reporters1xN or Nx1 array of string scalars or character vectors
1xN or Nx1 cell array of string scalars, character vectors, and/or DOM element objects
Use the Chapter
constructor or append
method to set this property. You cannot set it directly.
Layout
— Layout of this chapter
mlreportgen.report.ReporterLayout
Layout of this chapter, specified as an mlreportgen.report.ReporterLayout
object. Use the properties of
the ReporterLayout
object to override some of the chapter
layout properties that are defined in the template for the chapter.
Example: chapter.Layout.Landscape = true
TemplateSrc
— Source of template for reporter
[]
(default) | character vector | string scalar | reporter or report | DOM document or document part
Source of the template for this reporter, specified in one of these ways:
Character vector or string scalar that specifies the path of the file that contains the template for this reporter
Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter
DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter
The specified template must be the same type as the report to which you
append this report. For example, for a Microsoft® 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.
TemplateName
— Name of template for this reporter
character vector | string scalar
Name of the template for this reporter, specified as a character vector or string scalar.
The template for this reporter must be in the template library of the template specified by
the TemplateSrc
property of this reporter.
Data Types: char
| string
LinkTarget
— Hyperlink target for this reporter
[]
(default) | character vector | string scalar | mlreportgen.dom.LinkTarget
object
Hyperlink target for this reporter, specified as a character vector or string scalar
that specifies the link target ID, or an mlreportgen.dom.LinkTarget
object. A character vector or string scalar
value converts to a LinkTarget
object. The link target immediately
precedes the content of this reporter in the output report.
Methods
Public Methods
append | Add content to chapter |
add | (Not recommended) Add content to chapter |
getTitleReporter | Get chapter title reporter |
mlreportgen.report.Chapter.number | mlreportgen.report.Chapter.number(report,numbering)
specifies whether to number chapters in a report. If
numbering is true , all
chapters in the report are numbered. |
mlreportgen.report.Chapter.createTemplate |
|
mlreportgen.report.Chapter.customizeReporter | mlreportgen.report.Chapter.customizeReporter(toClasspath)
creates an empty class derived from the
Chapter reporter class with the name
toClasspath . You can use the generated class
as a starting point for creating a custom version of the
Chapter reporter. |
mlreportgen.report.Chapter.getClassFolder | mlreportgen.report.Chapter.getClassFolder()
returns the path of the folder that contains the class definition
file for the Chapter reporter class. |
copy | Create copy of reporter object and make deep copies of property
values that reference a reporter, ReporterLayout ,
or DOM element object |
getImpl | Get DOM implementation for this reporter |
Examples
Add a Chapter to a Report
Add a section to a chapter and the chapter to a report. Set the layout orientation of the chapter to landscape.
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report('My Report','pdf'); append(rpt,TitlePage(Title='My Report')); chapter = Chapter('Images'); chapter.Layout.Landscape = true; append(chapter,Section(Title='Boeing 747',Content=Image('b747.jpg'))); append(rpt,chapter); close(rpt); rptview(rpt);
Here is the first page of Chapter 1 in the generated report.
Version History
Introduced in R2017bR2020b: add
method is not recommended
Starting in R2020b, use the append
method instead of the
add
method to add content to objects of these Report API classes:
mlreportgen.report.Report
mlreportgen.report.Chapter
mlreportgen.report.Section
To add content to a DOM API object, such as an
mlreportgen.dom.Paragraph
object, continue to use the
append
method of the DOM object. The advantage of using
append
to add content to Report API objects is that you use
the same method name as you use to add content to DOM API objects.
There are no plans to remove the add
methods of the
Report
, Chapter
, or Section
classes. Report API programs that use the add
methods will continue
to run.
To update existing code, replace the method name add
with
append
as shown by the examples in the table.
Not Recommended | Recommended |
---|---|
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); add(sect,para); add(ch,sect); add(rpt,ch); close(rpt); rptview(rpt); |
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); append(sect,para); append(ch,sect); append(rpt,ch); close(rpt); rptview(rpt); |
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)