Main Content

mlreportgen.dom.CounterInc class

Package: mlreportgen.dom
Superclasses:

Number stream counter incrementers

Description

Create numbering stream counter incrementers.

Construction

counterIncObj = CounterInc() creates an empty counter incrementer.

counterIncObj = CounterInc(streamNames) creates a counter incrementer for each specified numbering streams. Assigning this format to the style of a DOM object causes the associated stream counters to be incremented when the object is appended to a document.

Input Arguments

expand all

Numbering stream names, specified as a character vector. To specify multiple stream names, add a space between the stream names.

Output Arguments

expand all

Numbering stream counter incrementers, represented by mlreportgen.dom.CounterInc objects.

Properties

expand all

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.

Numbering stream names, specified as a character vector. To specify multiple stream names, add a space between the stream names.

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.

Examples

collapse all

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'),WhiteSpace('preserve')};
append(p,AutoNumber('chapter'));
append(d,p);
     
p = Paragraph('Chapter ');
p.Style = {CounterInc('chapter'), WhiteSpace('preserve')};
append(p,AutoNumber('chapter'));
append(d,p);
     
close(d);
rptview('test',doctype);
import mlreportgen.dom.*
rpt = Document('MyReport','docx');

chapterStyle = {WhiteSpace('pre'), ...
    CounterReset('table figure'), ...
    CounterInc('chapter') ...
    };

topicChapterStyle = {WhiteSpace('pre'), ...
    CounterReset('table figure'), ...
    CounterInc('chapter topic') ...
    };

figureStyle = {WhiteSpace('pre'), ...
    CounterInc('figure'),Italic(true)};

chapter = Heading(1,'Chapter: ');
chapter.Style = chapterStyle;
append(chapter,AutoNumber('chapter'));
append(chapter,' Introduction to number streams.');
append(rpt, chapter);

image = append(rpt,Image(which('b747.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt, Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));

image = append(rpt,Image(which('ngc6543a.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt,Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));

 
chapter = Heading(1, 'Chapter: ');
chapter.Style = topicChapterStyle;
append(chapter, AutoNumber('chapter'));
append(chapter,' Topic: ');
append(chapter,AutoNumber('topic'));
append(chapter,' How to reset and increment streams.');
append(rpt,chapter);

image = append(rpt,Image(which('b747.jpg')));
image.Width = '2in';
image.Height = '2in';
para = append(rpt,Paragraph('Figure '));
para.Style = figureStyle;
append(para, AutoNumber('chapter'));
append(para, '.');
append(para, AutoNumber('figure'));

 
close(rpt);
rptview(rpt.OutputPath);