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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

Neeha Sompalli
Neeha Sompalli le 23 Avr 2019
Modifié(e) : Neeha Sompalli le 23 Avr 2019
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 !

Plus de réponses (0)

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by