How to set default font size in Matlab-published HTML?

9 views (last 30 days)
I'm using the publish command to produce HTML reports, and I'd like to change the default font size used by publish.m. Is there a way to do this?

Accepted Answer

Sai Sri Pathuri
Sai Sri Pathuri on 13 Jan 2020
When the HTML document is created with the PUBLISH function; it uses the 'mxdom2simplehtml.xsl' stylesheet.
You can modify the contents of the stylesheet and accordingly use it to generate HTML documents of your specification.
1) At the MATLAB command prompt, type:
fullfile(matlabroot,'\toolbox\matlab\codetools\private\')
2) Navigate to this folder and open up the XSL stylesheet named: mxdom2simplehtml.xsl
3) Now, search the document (using Ctrl+F) for the words " pre, code ". You will come to a location where the file reads:
pre, code { font-size:12px; }
Here, you can modify the font size of HTML report.
4) Save the changed file as 'mxdom2simplehtml2.xsl' in a location outside the matlabroot folder so that you do not overwrite the existing stylesheet.
For example, at a location like "C:\Users\username\Desktop\xslFiles".
5) Now, whenever you would like to use this size setting, you can use the following command in MATLAB:
publish('MATLABfile.m', 'stylesheet', 'C:\Users\username\Desktop\xslFiles\mxdom2simplehtml2.xsl')
This will make sure that the PUBLISH function uses this setting for the width while generating the HTML document.

More Answers (1)

Tor Wager
Tor Wager on 13 Jan 2020
Fabulous! Thank you.
This worked great for me, with a couple of minor modifications:
To load the file:
cd(fullfile(matlabroot,'toolbox', 'matlab', 'codetools', 'private'))
edit mxdom2simplehtml.xsl
This line changes the default body-text font size (to 12px from 10px):
html body { height:100%; margin:0px; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000; line-height:140%; background:#fff none; overflow-y:scroll; }
Saved this and used it in the option set:
mxdom2simplehtml_CANlab.xsl
p = struct('useNewFigure', false, 'maxHeight', 800, 'maxWidth', 800, ...
'format', 'html', 'outputDir', pubdir, ...
'showCode', true, 'stylesheet', which('mxdom2simplehtml_CANlab.xsl'));
publish(pubfilename, p)
Thanks again!

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!