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.dom.Heading2 class

Package: mlreportgen.dom
Superclasses:

Create Heading2 paragraph

Description

Create an mlreportgen.dom.Heading2 paragraph object.

Construction

headingObj = Heading2() creates an empty Heading2 object.

headingObj = Heading2(text) creates the heading containing the specified text.

headingObj = Heading2(text,styleName) creates the heading using the specified style.

headingObj = Heading2(domObj) creates the heading containing the specified DOM object.

Input Arguments

expand all

Heading text, specified as a character vector.

The name of a style, specified as a character vector. The style must be defined in the template used to create the document that contains this heading.

DOM object to include in the heading, specified as any of these DOM object types:

  • ExternalLink

  • Image

  • InternalLink

  • LinkTarget

  • Text

Properties

expand all

Background color, specified as either:

To make text bold, set this property to true or 1. If this property is empty and the StyleName property for this document element specifies a style sheet style, the weight of the text is determined by that style. Setting the Bold property adds a corresponding mlreportgen.dom.Bold format object to the Style property of this document element. Removing the Bold property setting removes the object.

Data Types: logical

This read-only property lists child elements of this object.

Text color, specified as either:

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

Amount by which to indent the first line of this paragraph relative to succeeding lines. To create a hanging indent, in which all the lines are indented except for the first line, use a negative number.

Specify the value in the form valueUnits, where Units is an abbreviation for the units. Use one of these abbreviations for the units.

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

The name of a font family.

To specify substitutions for this font, do not set this property. Instead create and add a mlreportgen.dom.FontFamily object to the Style property of this document element.

Setting the FontFamilyName property adds a corresponding mlreportGen.dom.FontFamily format object to the Style property for this document element. Setting the FontFamilyName property is the same as setting the FontName property of mlreportgen.dom.FontFamily. Removing the FontFamilyName property setting removes the object.

If you need to specify substitutions for this font, do not set this property. Instead create and add a mlreportgen.dom.FontFamily object to the Style property of this document element.

Setting the FontSize property adds a corresponding mlreportGen.dom.FontSize format object to the Style property for this document element. Removing the FontSize property setting removes the object.

Font size for text, in the form valueUnits, where Units is an abbreviation for the units. Use one of these abbreviations for the units:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

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

To use italics for text, set this property to true. If this property is empty and the StyleName property for this document element specifies a style sheet style, the slant of the text is determined by that style. Setting the Italic property adds a corresponding mlreportgen.dom.Italic format object to the Style property of this document element. Removing the Italic property setting removes the object.

Data Types: logical

Space between the left outer boundary of this paragraph and the left inner boundary of its container. This is equivalent to the left indentation property of a Microsoft® Word paragraph.

To indent a paragraph from both the left and right margin of a page, do not set this property. Instead, add to the Style property of this paragraph a mlreportgen.dom.OuterMargin object specifying the left and right indentations.

Setting the OuterLeftMargin property adds a corresponding mlreportGen.dom.OuterMargin format object to the Style property for this document element. Removing the OuterLeftMargin property setting removes the object.

The value has the form valueUnits, where Units is an abbreviation for the units. Use one of these abbreviations for the units:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Setting the OutlineLevel property causes this paragraph to be included in automatically generated outlines, such as a table of contents. The value specifies the level of the paragraph in the table of contents. For example, to make a paragraph appear as a Heading 1 (Word) or h1 (HTML), set OutlineLevel to 1.

Data Types: int32

This read-only property lists the parent of this document element.

Text strikethrough, specified as one of these values:

  • 'none' — Do not use strikethrough.

  • 'single' — Use a single line for strikethrough.

  • 'double' — Use a double line for strikethrough for Word documents.

Setting the Strike property adds a corresponding mlreportGen.dom.Strike format object to the Style property for this document element. Removing the Strike property setting removes the object.

Format objects that specify the format of a document element.

Name of the style to apply from the style sheet, specified as a character vector.

Tag for document element, specified as a character vector.

A session-unique ID is generated as part of document element creation. The generated tag has the form CLASS:ID, where CLASS is the class of the element and ID is the value of the Id property of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

You can specify one of the following types of underlines.

Border ValueDescriptionSupported Output Types

'dash'

Dashed underline

Word

'dashedHeavy'

Line with heavy dashes

Word

'dashLong'

Line with long dashes

Word

'dashLongHeavy'

Line with heavy long dashes

Word

'dashDotDotHeavy'

Line with heavy dashes with two dots between the dashes

Word

'dashDotHeavy'

Heavy dash-dot line

Word

'dotted'

Dotted line

Word

'dottedHeavy'

Thick dotted line

Word

'dotDash'

Dot-dash line

Word

'dotDotDash'

Dot-dot-dash line

Word

'dashDotHeavy'

Heavy dot-dash line

Word

'double'

Double line

Word

'none'

Do not use underlining

All output types

'single'

Single line

All output types

'thick'

Thick line

Word

'wave'

Wavy line

Word

'waveyDouble'

Double wavy line

Word

'waveyHeavy'

Heavy wavy

Word

'words'

Underline non-space characters only

Word

If this property is empty and StyleName property of this document element specifies a style sheet style, the type of underline is determined by that style.

To specify the color as well as the type of the underline, do not set the Underline property. Instead, set the Style property of this document element to include an mlreportgen.dom.Underline format object that specifies the desired underline type and color.

Setting the Underline property adds a corresponding mlreportgen.dom.Underline format object to the Style property for this document element. Removing the Underline property setting removes the object.

To specify how to handle white space, use one of these values.

ValueDescriptionSupported Output Types

'normal' (default)

For HTML and PDF, removes spaces at beginning and end of text. Multiple spaces within the text collapse to single space.

For Word, removes spaces at beginning and end of text.

All output types

'nowrap'

Sequences of white space collapse into a single white space. Text never wraps to the next line.

HTML

'preserve'

Preserves spaces and line feeds. Acts like the <pre> tag in HTML.

All output types

'pre'

Preserves white space. Text wraps only on line breaks. Acts like the <pre> tag in HTML.

HTML and PDF

'pre-line'

Sequences of white space collapse into a single white space. Text wraps.

HTML and PDF

'pre-wrap'

Preserves white space. Text wraps when necessary and on line breaks

HTML and PDF

Setting the WhiteSpace property adds a corresponding WhiteSpace format object to Style property. Removing the WhiteSpace property setting removes the WhiteSpace object.

Methods

Method

Purpose

append

Use Heading2.append similar to how you use Paragraph.append.

Append content to heading.

clone

Use Heading2.clone similar to how you use Paragraph.clone.

Copy heading.

Examples

expand all

This example shows how to add three levels of headings, each formatted according to its level. This example inserts three heading objects into a document: a Heading1, a Heading2, and a Heading3.

import mlreportgen.dom.*;
d = Document('mydoc','docx');
open(d);

title = append(d, Paragraph('Document Title'));
title.Bold = true;
title.FontSize = '28pt';

h1 = append(d,Heading1('Chapter 1'));
h1.Style = {PageBreakBefore(true)};
p1 = append(d,Paragraph('Hello World'));

h2 = append(d,Heading2('Section 1.1'));
p2 = append(d,Paragraph('Text for this section.'));

h3 = append(d,Heading3('My Subsection 1.1.a'));
p3 = append(d,Paragraph('Text for this subsection'));

close(d);
rptview(d.OutputPath);

Introduced in R2016a

Was this topic helpful?