# mlreportgen.report.Equation class

Package: mlreportgen.report
Superclasses: mlreportgen.report.Reporter

Equation reporter

## Description

Create an equation reporter that adds an equation to a report.

An equation is added to a report as an image of the formatted equation. By default, the image is embedded in an empty, centered paragraph. Optionally, it can be appended in line with other text in a paragraph. The image, and therefore, the equation can be scaled to any size.

The snapshot image of the equation is stored in the temporary folder of the report. When the report is closed, the equation image is copied into the report and, then, the image is deleted from the temporary folder. To prevent the equation image files from being deleted, use the Debug property of the report. See mlreportgen.report.Report.

The mlreportgen.report.Equation class is a handle class.

### Class Attributes

 HandleCompatible true

For information on class attributes, see Class Attributes (MATLAB).

## Creation

### Description

 equation = mlreportgen.report.Equation() creates an empty equation reporter object. Use the object properties to specify the equation and its formatting.

example

equation = mlreportgen.report.Equation(markup) formats the equation that is specified by the LaTeX markup for the equation. See the Content property.
equation = mlreportgen.report.Equation(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single or double quotes.

## Properties

expand all

LaTeX markup for the equation, specified as a string scalar or character vector. You can use any LaTeX markup that is supported by the Interpreter property of a MATLAB® text object. See Text Properties.

Font size for the formatted equation, specified as empty, or as a positive integer. If the FontSize property is empty, the font size defaults to 10.

Name of font color for the formatted equation, specified as empty, or as a string scalar or character vector. If the Color property is empty, the font color defaults to black. You can use long or short color names. For a list of valid color names, see the Color property in Text Properties.

Name of background color for the formatted equation, specified as empty, or as a string scalar or character vector. If Color is empty, the background color defaults to white. You can use long or short color names. For a list of valid color names, see the Color property in Text Properties.

Display equation in line with text, specified as true or false.

If the DisplayInline property is set to false, the reporter takes an image of the equation, wraps the image in a paragraph, and adds the paragraph to the report. In the report, the equation is on a line by itself. See Add an Equation to a Chapter. Use this option to fill block holes in a template.

If the DisplayInline property is set to true, the equation image is not wrapped in a paragraph. To add the equation to the report, get the equation image by using the getImpl method and then add the image to a paragraph. In the generated report, the equation is in line with the text of a paragraph. See Display Equation in Line with the Text of a Paragraph. Use this option to fill inline holes in a template.

### Note

By default, the bottom of an inline image is aligned with the base line of the surrounding text. If an inline equation image is taller than the surrounding text, you can use the mlreportgen.dom.VerticalAlign format to align the image relative to the text base line so that the equation base line matches the text base line. You must experiment to determine the required amount of vertical adjustment.

Snapshot image format, specified as a character vector or string scalar. Supported formats are:

• "png" — PNG image.

• "emf" — Enhanced metafile. This format is supported only in DOCX output on Windows® platforms.

• "svg" — Scalable Vector Graphics.

Source of the template for this reporter, specified in one of these ways:

• Character vector or string scalar that specifies the path of the file that contains the template for this reporter

• Reporter or report whose template is used for this reporter or whose template library contains the template for this reporter

• DOM document or document part whose template is used for this reporter or whose template library contains the template for this reporter

The specified template must be the same type as the report to which this reporter is appended. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template. If the TemplateSrc property is empty, this reporter uses the default reporter template for the output type of the report.

Name of the template for this reporter, specified as a character vector or string scalar. The template for this reporter is in the template library of the template source (TemplateSrc) for this reporter.

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar value is converted to a LinkTarget object. The link target object immediately precedes the content of this reporter in the output report.

expand all

## Examples

collapse all

Create a report that includes an equation in a chapter. By default, the reporter adds an image of the equation on a separate line of the report.

% Import the API packages import mlreportgen.report.* % Create the report and chapter % Add an equation as a separate line in the chapter rpt = Report('equation','docx'); ch = Chapter('Title','Equation'); add(ch,Equation('\int_{0}^{2} x^2\sin(x) dx')); add(rpt,ch); % Close and view the report. close(rpt); rptview(rpt); 

Create a report that includes an equation on a yellow background in 14-pt font.

% Import the API packages import mlreportgen.report.* % Create the report and chapter % Create an Equation reporter and set the FontSize and Color properties rpt = Report('equation','docx'); ch = Chapter('Title','Equation'); eq = Equation; eq.Content = '\int_{0}^{2} x^2\sin(x) dx'; eq.FontSize = 14; eq.Color = 'b'; eq.BackgroundColor = 'y'; add(ch,eq); add(rpt,ch); % Close and view the report close(rpt); rptview(rpt); 

Create an equation that is in line with the text of a paragraph by setting the DisplayInline property to true. Then, call the getImpl method to get the image snapshot of the equation. Add the snapshot of the image to the paragraph.

% Import the API packages import mlreportgen.report.* import mlreportgen.dom.* % Create report % Add equation in line with text in a paragraph of the report rpt = Report("equation", "docx"); eq = Equation("\int_{0}^{2} x^2\sin(x) dx"); eq.DisplayInline = true; img = getImpl(eq, rpt); img.Style = {VerticalAlign("-5pt")}; p = Paragraph("Here is an inline equation: "); p.WhiteSpace = 'preserve'; append(p,img); append(p," More text "); add(rpt,p); % Close and view the report close(rpt); rptview(rpt);

## Compatibility Considerations

expand all

Behavior changed in R2019b