I'm doing a presentation system in QML (with C++ backend) similar to this one.
I want to be able to include some Latex code to display some math (only minimum Latex capabilities needed, such as sums, fractions, super- and substript and math fonts).
I see the following possibilities to do so:
latex
)dvisvgm
)Image
in QML (which also supports SVG)WebKit
for QMLQDeclarativeItem
with custom paintingIs there another solution I don't see? I prefer the first solution as the second sounds too heavy and the third too hard.
I see the following problem with the baseline of the math formula: I want to be able to include inline formulas (within a paragraph). Currently, text paragraphs are renderd using a QML Text element. Is there a possibility to include an image in a Text element (using HTML img element maybe) with a specified baseline? Also, how can I determine the baseline of a rendered Latex document?
Note: The time to pre-render Latex code isn't problematic. I'm going to cache already rendered formulas, so it should be no problem to invoke latex
+ dvisvgm
on every single formula contained in the presentation document.
Also note that I use a preprocessor (I don't write the QML code by hand but generate it). So I don't need a QML element for the Latex code but I can just generate a QML code snippet with an Image element (for the first solution). This should simplify embedding the rendered image.
I also don't need to support wrapping a formula when using inline Latex. (Latex does so when writing inline formulas, but I only use small formulas I don't want to be wrapped anyways.)
I think those are three good options, and I can't think of any other way to do it.
It sounds like you have a requirement to have the formulas in-line with some textual paragraphs, so for that reason I think option 2 is a good way to do it.
It isn't difficult to use the WebKit component. I'm not sure what you mean by "too heavy".
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With