Main Content

getTitleReporter

Class: mlreportgen.report.Section
Namespace: mlreportgen.report

Create a section title reporter

Syntax

reporter = getTitleReporter(section)

Description

reporter = getTitleReporter(section) creates an mlreportgen.report.SectionTitle reporter that is partially configured to:

  • Format the value of the Title property of the mlreportgen.report.Section reporter specified by section.

  • Fill the Title hole in the Section reporter template with the formatted title.

The SectionTitle reporter getImpl method uses the mlreportgen.report.Section.getTitleReporter method to format inline title content. You can use the mlreportgen.report.Section.getTitleReporter method to customize inline title format as follows:

  1. Invoke the mlreportgen.report.Section.getTitleReporter method to get a default SectionTitle reporter.

  2. Customize the SectionTitle reporter properties. For example, specify a template source that contains customized title templates.

  3. Set the Title property of the Section reporter to the customized SectionTitle reporter.

You can customize the title format by changing the default values of these SectionTitle reporter properties:

  • TemplateSrc

    This property is set by default to the Section reporter template. The template library of this template contains default section title templates named:

    • SectionTitle1, SectionTitle2, and so on, for unnumbered titles

    • SectionNumberedTitle1, SectionNumberedTitle2, and so on, for hierarchically numbered titles.

    You can set this property to the source of a template file that contains custom definitions of these templates.

  • TemplateName

    This property is set by default to 'SectionNumberedTitle' if the Section reporter Numbered property is true (the default). Otherwise, this property is set to 'SectionTitle'. You do not need to change this setting if your custom template library customizes the definitions of the standard title templates, but not their names. For example, if your template library contains a template named SectionNumberedTitle1 with a customized version of the standard definition for SectionNumberedTitle1, you do not need to change the value of this property.

  • OutlineLevel

    This property is empty by default. The Section reporter getImpl method, which invokes the getTitleReporter method by default, sets this property to a section level when the Section reporter is added to the report. The SectionTitle reporter then appends the value of the OutlineLevel property to the value of the TemplateName property to create the full name of the SectionTitle template for the section level, for example, SectionNumberedTitle2 for a second-level subsection.

  • Content

    This property is set by default to the value of the Section reporter Title property.

  • NumberPrefix

    This property is set by default to [].

  • NumberSuffix

    This property is set to '. ' if the Section Numbered property is true (the default). Otherwise, this property is set to [].

  • Translations

    This property is not set by default. Set this property to localize the section title number prefix and suffix title content.

Input Arguments

expand all

Section of the report, specified as an mlreportgen.report.Section object.

Output Arguments

expand all

Section title reporter, returned as an mlreportgen.report.SectionTitle object.

Examples

expand all

The following example shows how to use a custom template to generate the title of a level one section in a report.

Suppose that MyCustomTemplate.pdftx contains a customized version of the standard template SectionNumberedTitle1.

To use the custom template:

  1. Get the SectionTitle reporter for the section.

  2. Set the TemplateSrc property of the reporter to MyCustomTemplate.pdftx and set the OutlineLevel property to the level of the section.

  3. Set the Title property of the Section reporter to the SectionTitle reporter.

For example:

import mlreportgen.report.*

rpt = Report("myrpt","pdf");

sec = Section("Title","Introduction");
titleRptr = getTitleReporter(sec);
titleRptr.TemplateSrc = "MyCustomTemplate.pdftx";
titleRptr.OutlineLevel = 1;
sec.Title = titleRptr;
add(rpt,sec);
close(rpt);

Version History

Introduced in R2017b