MATLAB: Is there a way to create subsections using ‘publish’

generatorMATLABpublishreportsubsection

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?

Best Answer

There is no special syntax for creating subsections/subheadings using the 'publish' feature, like there is for creating main section headings. However, you can create subsections by specifically including the {h3} tag in your document surrounded by {html} tags. For example:
%% Main Section
% H2 tags are used to denote main sections.
% But you can specifically write H3 tags using HTML, for example:
%

% <html><h3>Sub Section</h3></html>
%
% This text will be in a sub-section.
 
If you want to change the formatting of the subheading, you can do that by modifying the CSS information included in the XSL stylesheet that does the transformation into HTML. Then you can instruction 'publish' to use the custom stylesheet using the 'stylesheet' input parameter.
 
publish('fcn.m','stylesheet','mystylesheet.xsl')
The default stylesheet can be found by executing the following command in MATLAB:
which -all mxdom2simplehtml.xsl
The subsection will not be automatically included in the table of contents, but you may be able to add the subsections to the table of contents by modifying the XSL stylesheet.
As an alternative to the 'publish' feature, the MATLAB Report Generator can be used to generate much more complicated and elaborate reports based on your data. You may find that it is better suited for your needs than the 'publish' function. For more information on the MATLAB Report Generator, please visit the following link: