How to modify the alignment of an equation in the report generator and/or embed it in a paragraph or table

9 次查看(过去 30 天)
Hello,
I'm trying to figure out how to modify the horizontal alignment of an equation using Equation() in the report generator and also embed it into a paragraph or table.
The code is similar to the following:
import mlreportgen.dom.*;
import mlreportgen.report.*
d=Report('Myreport','pdf');
open(d);
Equ=Equation();
Equ.Content='10\leq\beta\leq40';
Equ.FontSize = 12;
The problem is, the equation is always placed at the center of a line, while in my report it's required to put it inline with other texts or in a table. I already used "append" and "add" together but it didn't work.
A code that doesn't work is similar to:
tablequ=Table({Equ});
tablequ.TableEntriesVAlign=('middle');
tablequ.TableEntriesHAlign=('left');
add(d,tablequ);
close(d);
What is desplayed is : "[1x1 mlreportgen.report.Equation]"
Any help is most appreciated.
Yasser

采纳的回答

Neeha Sompalli
Neeha Sompalli 2019-4-23
编辑:Neeha Sompalli 2019-4-23
Hi Yasser,
Equation() takes input as Latex text. So, in order for it to appear as a Latex text, you should use getSnapshotImage() method and wrap it around the DOM Image. Using this you could append to a paragraph or a table.
Please see the example below:
import mlreportgen.dom.*;
import mlreportgen.report.*
rpt=Report("Myreport","pdf");
Equ=Equation("10\leq\beta\leq40");
Equ.FontSize = 12;
% get the snapshot of the equation Image
img = Image(getSnapshotImage(Equ, rpt));
p = Paragraph("This is inline equation");
append(p, img);
append(p, "some more text");
add(rpt,p);
close(rpt);
rptview(rpt);
In the above example, an equation is getting appended inline with the texts of Paragraph.
Hope this helps !

更多回答(0 个)

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by