Main Content

mlreportgen.dom.LOF class

Package: mlreportgen.dom
Superclasses: mlreportgen.dom.LOC

List of figures

Since R2020b

Description

Use an object of the mlreportgen.dom.LOF class to create a list of figures in a report.

Each list item contains the caption of a figure (image) and links to the caption in the report. In a PDF or Microsoft® Word report, a list item also includes the page number and a leader that fills the space between the caption and page number. In a PDF or Word report, the list is located at the point in the report where you append the LOC object. In an HTML report, the list is located in a sidebar with the title List of Figures.

The way a list is generated depends on the report type.

  • PDF — The DOM API generates the list during report generation.

  • Word — The DOM API generates a placeholder for the list. To generate the list items, you must update the Word document in your report generation program or in Word. See Update Tables of Contents and Generated Lists in Word Documents.

  • HTML — The DOM API generates a placeholder for the list. When the report opens in an HTML browser, the browser generates the list.

To include figures (images) in the list of figures:

  1. Create captions for the figures using mlreportgen.dom.Paragraph objects.

  2. Associate the Paragraph objects with a numbering stream that has the name figure by using an mlreportgen.dom.AutoNumber object.

The mlreportgen.dom.LOF class is a handle class.

Class Attributes

ConstructOnLoad
true
HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

example

lofObj = mlreportgen.dom.LOF() creates an mlreportgen.dom.LOF object and sets the LeaderPattern property to '.'.

lofObj = mlreportgen.dom.LOF(leaderPattern) creates an mlreportgen.dom.LOF object and sets the LeaderPattern property to the specified leader pattern.

Properties

expand all

Name of numbering stream, specified as 'figure'. Do not change the value of this property. To create a list of captions using a custom numbering stream name, use an mlreportgen.dom.LOC object.

Type of leader to use between the caption and the page number, specified as one of these character vectors or string scalars:

  • '.' or 'dots'

  • ' ' or 'space'

This property applies only to PDF reports. Word reports always have a dots leader. HTML reports do not have a leader.

Name of the stylesheet-defined style for the list of figures, specified as a character vector or string scalar.

The style specified by the StyleName property must be defined in the stylesheet of the document or document part to which this list of captions is appended. The specified style defines the appearance of the list of figures in the output document. Formats specified by the Style property override formats defined by the stylesheet.

Formats that define the style of the list of figures, specified as a cell array of DOM format objects. The formats override the corresponding formats defined by the stylesheet style specified by the StyleName property. Formats that do not apply to a list of figures are ignored.

Custom attributes of this document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output format.

Parent of this document element, specified as a DOM object. This property is read-only.

Attributes:

GetAccess
public
SetAccess
private
NonCopyable
true

Children of this document element, specified as an array of DOM objects. This property is read-only.

Tag for this document element, specified as a character vector or string scalar.

The DOM generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Methods

expand all

Examples

collapse all

Create a list of figures as an mlreportgen.dom.LOF object. To include figures in the list:

  • Create captions for the figures as mlreportgen.dom.Paragraph objects.

  • Associate the Paragraph objects with a numbering stream that has the name figure.

Import the DOM package so that you do not have to use long, fully qualified class names.

import mlreportgen.dom.*

Create a report.

d = Document("DOM Report with List of Figures","docx");

Create an LOF object and append it to the report.

LOFObj = LOF();
append(d,LOFObj);
append(d,PageBreak);

Include an image (figure) in the report.

append(d,Image('peppers.png'));

Create a paragraph for the figure caption.

p1 = Paragraph("Figure ");

Create an automatic numbering stream with the name figure and associate it with the paragraph.

append(p1,AutoNumber("figure"));

Increment the counter for the numbering stream.

p1.Style = {CounterInc("figure"),WhiteSpace("preserve")};

Append the rest of the caption text to the paragraph and append the paragraph to the report.

append(p1,".");
append(p1," Peppers");
append(d,p1);

Include another image in the report and create a caption for the figure. Associate the caption with the figure numbering stream.

append(d,Image("b747.jpg"));
p2 = Paragraph("Figure ");
append(p2,AutoNumber("figure"));
p2.Style = {CounterInc("figure"),WhiteSpace("preserve")};

Append the rest of the caption text to the paragraph and append the paragraph to the report.

append(p2,".");
append(p2," Airplane");
append(d,p2);

Close and view the report.

close(d);
rptview(d);

Here is the list of figures in the generated report:

Version History

Introduced in R2020b