Section headings in HTML created using the 'publish' function use the {h2} tags. Is there a way to create subsections that use the {h3} tag and have them included in the table of contents?
MATLAB: Is there a way to create subsections using ‘publish’
generatorMATLABpublishreportsubsection
Related Solutions
The report generation in MATLAB allows you to create a custom template for reporters using 'customizeReporter' method for reporter classes in mlreportgen.report.*. You can create a custom chapter template first and add holes to create a footer in the PDF template. For reference, template holes are places in a template that the report program fills with content.
The following steps illustrate how to add a footer in the report:
Step 1 – Create a custom chapter class with the following command:
>> mlreportgen.report.Chapter.customizeReporter('@customChapter'); This will create a folder named '@customChapter' in your current directory. It contains the file 'customChapter.m' and a resource directory.
Step 2 – Navigate to the PDF template - @customChapter/resources/templates/pdf, unzip the PDF template using the command:
>> unzip("default.pdftx","default") This will create a folder named “default” with "root.html" and "docpart_templates.html"
Step 3 – Edit the PDF template to add a footer containing a hole. For example, you can update the "docpart_templates.html" with following code in the <body> section :
......<layout> <pfooter type="default" template-name="MyPageFooter"/></layout>::<dptemplate name="MyPageFooter"> <p style="text-align:right;font-family:Arial,Helvetica,sans-serif;font-size:10pt"> <hole id="PageFooterHole1" /> </p> </dptemplate>......
For more details on how to add footer, refer to
https://www.mathworks.com/help/releases/R2018a/rptgen/ug/add-page-footers-and-headers.html#bu710dp-1
Step 4 – Zip the template (remember to be on the path @customChapter/resources/templates/pdf:
>> zipTemplate("default.pdftx","default")
Step 5 – Edit 'customChapter.m' and add a property that matches the hole ID in the template. Each hole in the report will be replaced by the value of the corresponding property of the report. In this case, create property name 'PageFooterHole1' for 'customChapter' class.
Step 6 – Create a chapter with custom chapter template. Set the content for the footer hole by setting the corresponding property of the report object. In this example, following code would create report and add a chapter with desired footer content:
>> rpt = Report('test','pdf'); %create a report object
>> ch = customChapter;>> tp = TitlePage; %create a title page
>> tp.Title = 'Test Case Results';>> tp.Subtitle = 'Subtitle';>> tp.Author = 'John';>> add(rpt,tp);>> ch.PageFooterHole1 = mlreportgen.dom.Text("This is my footer1");>> add(rpt,ch);>> add(rpt, "body content");>> add(rpt, mlreportgen.dom.PageBreak);>> add(rpt, "body content");>> close(rpt);>> rptview(rpt); % To view the report
This will create a PDF report with a title page and a chapter with two pages showing the footer with the style specified in "docpart_templates.html".
Files are attached for reference.
Please note that you can adapt this method to add headers as well or any other customization needed by your workflow. For instance, the following MATLAB Answers post discusses an approach to add an image to a header:
The ability to change the title font size from within the MATLAB Report Generator R2010b (3.9) GUI is not available.
As a workaround, open the stylesheet (RGS) file in a text editor and add the following lines just before </xsl_code>.
<xsl:template match="title" mode="chapter.titlepage.recto.auto.mode"> <fo:block xmlns:fo="<http://www.w3.org/1999/XSL/Format http://www.w3.org/1999/XSL/Format"> xsl:use-attribute-sets="chapter.titlepage.recto.style" font-size="24pt" font-weight="bold"> <xsl:call-template name="component.title"> <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/> </xsl:call-template> </fo:block> </xsl:template>
Modify the "font-size" parameter value at on the second line as needed, the code above uses "24pt".
Execute the "rptconvert -clearcache" on the MATLAB command prompt after every modfication that is made to the stylesheet file to ensure that the changes take effect in the generated report.
Note: this workaround could only work with PDF file. There is no workaround for Word file.
Related Question
- How to use MathJax to render the LaTeX math in the published output in MATLAB 7.10 (R2010a)
- How to remove the Paragraph environment generated when publishing an MATLAB file into LaTeX in MATLAB 7.8 (R2009a)
- How to launch a Polyspace report automatically in PolySpace Client for C/C++
- How to add current date and time to a footer in the report in the MATLAB Report Generator
Best Answer