reporter templates -凯发k8网页登录

main content

reporter templates

this reference describes the templates used by these reporters:

use this information to create custom templates for use with one of these reporters or from a reporter derived from these reporters.

section templates

the section reporter uses six sets of templates for each of the three output types supported by matlab® report generator™: docx, pdf, and html. each set corresponds to the six levels of section hierarchy that the section reporter can generate. the first set corresponds to a top-level section, the second set to a second-level subsection of a top-level section, and so on.

each level set contains three templates:

a section reporter determines which set to use when your report program adds the reporter to a report object. for example, when your report program adds a section reporter to a report object, the section reporter uses the top-level template set. a section reporter uses the second-level template set when the report's add method adds it to the report as part of the content of a top-level section reporter. a section reporter uses the third-level template set when the report add method adds it to the report as part of the content of a second-level reporter, etc.

section1 template

the section reporter's word, pdf, and html section1 templates specify the format of a top-level section generated by the section 1 reporter in a word, pdf, and html report, respectively. all three templates specify the location of the holes and the default styles for the section reporter's title and content properties.

in addition, the pdf and word templates specify the page layout properties of a top-level section, including page orientation, margins, page headers, and page footers of a top-level word or pdf section. the word and pdf templates specify a different header for the first page of a section and for the pages that follows. the header of the first page contains only a rule. the header of subsequent pages, called default header, contains the section title. the first page footer and subsequent page footers are identical.

a top-level section starts on a new page having the properties specified by the top level section reporter's template. all subsequent pages needed to accommodate the top-level section content have the same page layout, unless the content itself specifies a new page layout, in which case, the page layout of subsequent pages changes. default lower-level section templates do not specify a page layout. as a result, adding subsections to a section does not change the page layout. the content of subsections has the same layout as the top-level sections.

  • word section1 template

    the word section1 template resides in the quickparts gallery of the section reporter's default.dotx template file. the quickparts gallery serves as the section reporter's word template library. to view or edit the section1 template, you must open the default.dotx file in word and create an instance of the template in the default.dotx template . the section1 template appears as follows in word:

    note

    when you display a copy of the word section1 template, it scrolls to the default page header on the second page, which displays an error message. refer to the note below for an explanation of this error message. to see the template holes, scroll to the top of the template.

    the section 1 template specifies a header for the first page of a section that differs from the header of succeeding pages. the header of all but the first page is called the default header. the first page header contains a rule but is otherwise empty.

    note

    the rule is implemented as an empty paragraph with a bottom border. the font size of the paragraph is set to a very low value to minimize the paragraph's height.

    the first page footer contains a word page number field. when this template or a report generated from it is opened in word, word replaces the field with the number of the page on which the footer appears.

    the section1's default page header contains a word styleref field that references the section's title style (that is, sectiontitle). when the template or a report generated from the template is opened in word, word replaces the styleref field with the content of the first paragraph in the section that has the sectiontitle style. in a report, that paragraph contains the section's title. thus, the section's title appears in page headers that follow the first page. (this is called a running head in document design.)

    note

    the section1 template occupies less than a page. thus, when you copy the section1 template from the section reporter's quickpart's gallery (that is, template library) to the body of the default.dotx template, only the first page of the section appears. however, word creates a page with a new section (section 2) that inherits the section1 template's page headers. word replaces the styleref field in the header of this new section with an error message because there is no paragraph in the new section with the referenced style.

    the section1 template specifies a default page footer that is identical in content and format to the first page footer.

    note

    to view or edit the default page footer, you must insert a page in the section1 template as follows:

    1. copy the template from the section reporter template's quickparts gallery (that is, its template library) to the body of the reporter template.

    2. insert a paragraph after the content hole in the template.

    3. enable the paragraph's page break before property.

  • pdf section1 template

    the pdf section1 template resides in the template library of the section reporter's pdf template file (default.pdftx). the template file is a zip file. it stores the template library in a file named docpart_templates.html. to view or edit the section1 template:

    1. unzip a copy of the default.pdftx file using the report api unziptemplate command.

    2. open the docpart_templates.html file in the matlab editor or any other text editor.

    3. when you are finished editing the section1 template, save the docpart_templates.html file.

    4. rezip the default.pdftx file, using the report api ziptemplate command.

    for more information, see .

    the pdf section1 template uses the following html markup to define the page layout of a top-level pdf section generated by the section reporter. the markup also defines the location of the holes to be filled with the content of the section reporter's title and content properties.

    the pheader and pfooter elements in the section1 layout specify templates used to define the content and layout of a top-level section's page headers and footers. the header and footer templates reside in the same template library file (docpart_templates.html) as the section1 template itself. the section reporter uses only the first page and default page templates.

    the first page header and footer templates are

    the header template specifies an empty paragraph followed by a horizontal rule. the empty paragraph specifies the style sectiontitlehead. it is defined in the template's style sheet (see below). the first page footer template specifies a horizontal rule followed by a page number.

    the default page header template

    specifies a paragraph containing a styleref followed by a horizontal rule. during report generation, the report api replaces the styleref element with the content of the top-level section's title paragraph, thereby creating a running head.

    the default page footer template

    specifies a horizontal rule followed by an automatically generated page number.

    the styles for the header and footer templates are in the pdf/stylesheets/root.css file.

  • html section1 template

    the section1 document part template in the default.htmt file specifies the title and content holes.

section2 – section6 templates

the section2-section6 templates specify the format of subsections generated by the section reporter. each template contains hole elements that specify the location of holes to be filled with the content of the section reporter's title and content properties, respectively. the title hole in each template specifies a default title style specific to the subsection level defined by the template.

  • word section2 – section6 templates

    as an example, this image shows the section2 template.

  • pdf and html section2 – section6 templates

    as an example, this image shows the section2 template.

section template holes

all of the section templates (section1 – section6) have the holes described in this table.

hold idhole typedescription

title

block

the section reporter fills this hole with content based on the type of the content of its title property as follows.

  • if the title property content is an inline object, such as a string or mlreportgen.domtext object, the section reporter uses a sectiontitle reporter to format and generate the inline content as a title. it then adds the generated content to the title hole. the sectiontitle reporter use templates to format the inline content.

  • if its title property content is a paragraph or other block-level object, the section reporter adds the paragraph to the title hole.

  • if its title property content is another reporter, the section reporter adds the content generated by the reporter to the title hole.

content

block

content of the section

section template styles

the section templates use styles to format some content. the word templates define the styles they use in the style sheet in the default.dotx template file. the pdf and html templates define the styles in the stylesheets/root.css file in the default.pdftx and default.htmt files, respectively. the following table describes the styles used by the section templates.

style namestyle typedescription

sectioncontent

character

the content hole in the section1-section6 templates specify this style as the default text style for content that fills the hole. the content can specify styles or formats that override the default style.

sectiontitle1 - sectiontitle6

character

the title hole in the corresponding section template specifies the corresponding style name as the default style for the section's title. for example, the title hole in the section1 template specifies sectiontitle1 as the name of the default style for the title of a top-level section. content added to the title hole can specify formats or styles that override the default style.

sectiontitleheader

character

the section1 page headers use this style to center the header content.

sectiontitlefooter

character

the section1 page footers use this style for the footer content.

section title templates

if the content of the section reporter's title property is a string, text, or other inline object, it uses a sectiontitle reporter to generate the content used to fill the title hole in its section level templates. the sectiontitle reporter in turn uses templates to format the inline content as a title. the sectiontitle reporter use two sets of templates for each output type, one to create hierarchically numbered titles (1.1, 1.2, 1.2.1, and so on), the other to create unnumbered titles. each set contains six templates corresponding to the six levels of sections that the section reporter can generate. the templates reside in the template libraries of the section reporter's word, pdf, and html template files, default.dotx, default.pdftx, and default.htmt, respectively.

numbered section title templates

if a report or section reporter specifies that its titles be numbered, the sectiontitle reporter uses automatically numbered templates to format the inline content of the section reporter's title property. the titles are named sectionnumberedtitlen, where n is the section level to which the template applies. for example, the name of the template for a top-level section title is sectionnumberedtitle1. each template contains a paragraph element that specifies the same style as is specified by the title hole in the corresponding section level template, for example, sectiontitle1 for a top-level section title. see section template styles.

the title paragraph contains the following holes.

  • numberprefix hole to be filled with the content of sectiontitle reporter's numberprefix property (empty by default)

  • autonumber markup that is replaced by a hierarchical number during report generation. the autonumber markup differs for each level template so as to generate the hierarchical number appropriate to that level.

  • numbersuffix hole to be filled with the content of the sectiontitle reporter's numbersuffix property (empty by default).

  • content hole to be filled with the content of the sectiontitle reporter's content property.

the following images show the word, pdf, and html sectionnumberedtitle1 templates, respectively. lower-level templates are similar.

  • word sectionnumberedtitle1 template

  • pdf sectionnumberedtitle1 template

  • html sectionnumberedtitle1 template

during report generation, the section reporter sets the content property of the sectiontitle reporter to the inline content of the section reporter's title property. it does not set the numberprefix and numbersuffix properties. as a result, the title generated by the sectiontitle reporter consists by default of a hierarchical number followed by the title text.

the sectiontitle reporter provides the numberprefix and numbersuffix holes to facilitate labeling of titles by derived reporters. for example, the chapter reporter, which is derived from the section reporter, sets the numberprefix property to chapter in english locales. in some east asian locales, the chapter reporter sets the numbersuffix to the character designating chapter.

note

if you customize a numbered section template, do not remove or replace the seq fields in a word template or the autonumber markup in a pdf or html template. to generate unnumbered sections, use the unnumbered section title templates.

sectionnumberedtitle template holes

all of the sectionnumberedtitle templates (section1 – section6) have the holes described in this table.

hole idhole typedescription

numberprefix

inline

prefix to display before the section number.

numbersuffix

inline

suffix to display after the section number.

content

inline

content of the title

unnumbered section title templates

if the report specifies that the current section uses unnumbered titles, the sectiontitle reporter uses unnumbered templates to generate section titles. the unnumbered templates are named sectiontitlen where n is the level of the section whose title is to be generated. for example, the template for a top-level section is named sectiontitle1. each template contains a paragraph element that specifies the same style as is specified by the title hole in the corresponding section level template, for example, sectiontitle1, for a top-level section title. see section template styles. the title paragraph contains a hole to be filled by the content of the sectionreporter's content property (set by the section reporter during report generation).

the follow images show the word, pdf, and html versions of the sectiontitle1 templates. lower-level templates are similar.

  • word sectiontitle template

    all levels of the word sectiontitle templates have the same content hole.

  • pdf and html sectiontitle1 template

  • pdf and html sectiontitle2 – sectiontitle6 templates

    these section title templates include a content hole, as in sectiontitle1 template. each of these sections specifies its title style.

sectiontitle template hole

all of the sectiontitle templates (section1 – section6) contain the hole described in this table.

hole idhole typedescription

content

inline

content of the title

chapter templates

the chapter reporter, a subclass of the section reporter, uses the section reporter's top-level template set to generate its content. this is because a chapter-generated section is nearly identical to a section-generated section. however, the two types of sections differ in two respects:

  • the title of a chapter section contains the word chapter in english locales or the equivalent in other locales supported by the report api. the chapter reporter includes the word chapter in titles by setting the numberprefix or numbersuffix properties of the sectiontitle reporter used to generate the chapter title.

  • all section-generated top-level sections start on page 1. by contrast, only the first chapter generated by a chapter reporter starts on page 1. succeeding chapters continue page numbering from the previous chapter. the chapter reporter implements this behavior programmatically, thus avoiding the need to use a modified version of the section top-level template.

see section1 template, numbered section title templates, and unnumbered section title templates

网站地图