MATLAB: How to inline an equation with HTML text in a Simulink Report

equationhtmlinline()reportsimulinkSimulink Report Generatortext;

Best Answer

In order to inline an equation with HTML text, you can use the HTML paragraph. The HTML object has a paragraph as its child. Therefore, you can append the inline equation image to this paragraph. For example:
>> html = HTML('<p><b>Hello</b> <i style="color:green"> World</i></p>');
% Create an example equation
>> eq = Equation("\int_{0}^{2} x^2\sin(x) dx");
>> eq.DisplayInline = true;
>> eq.FontSize = 14;
% Get equation image
>> eqImg = getImpl(eq,rpt);
>> eqImg.Style = {VerticalAlign("-5pt")};
% Append equation image to HTML
>> append(html.Children, eqImg);
Another way to achieve this is to add the image to the HTML text using an <img> element instead of using <a> link element. For example, if you have an equation image in your current directory titled "myEqImg.svg", you can use the following HTML code:
>> html = HTML('<p><b>Hello</b> <i style="color:green"> World</i><img src="myEqImg.svg"/></p>');