将乳胶嵌入QML的可能性 [英] Possibilities to embed Latex in QML

查看:97
本文介绍了将乳胶嵌入QML的可能性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用QML(具有C ++后端)进行演示的系统,类似于

I'm doing a presentation system in QML (with C++ backend) similar to this one.

我希望能够包含一些Latex代码来显示一些数学运算(仅需要最低的Latex功能,例如求和,小数,超和亚带和数学字体).

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:

  • 使用 latex2e :
  1. 将Latex代码编译为DVI文档(使用latex)
  2. 使用dvisvgm将DVI转换为SVG
  3. 在QML(也支持SVG)中使用Image显示此内容
  1. Compile the Latex code to a DVI document (with latex)
  2. Convert the DVI to SVG (with dvisvgm)
  3. Display this using an Image in QML (which also supports SVG)

  • 使用 MathJax :
  1. 将Latex代码包装在一个小的HTML文件中,并包含MathJax JS库
  2. 使用WebKit显示QML
  1. Wrap the Latex code in a small HTML file + include the MathJax JS library
  2. Display this using WebKit for QML

  • 自定义解决方案(C ++):
  • Custom solution (C++):
  1. 编写或包括一个现有的最小Latex数学解析器
  2. 用自定义绘画写一个QDeclarativeItem

还有其他我看不到的解决方案吗?我喜欢第一种解决方案,因为第二种听起来太沉重,第三种听起来太辛苦.

Is there another solution I don't see? I prefer the first solution as the second sounds too heavy and the third too hard.

我发现数学公式的基线存在以下问题:我希望能够包含内联公式(在一个段落中).当前,文本段落是使用QML Text元素呈现的.是否可以将图像包含在具有指定基线的Text元素中(可能使用HTML img元素)?另外,如何确定渲染的Latex文档的基线?

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?

注意:预渲染Latex代码的时间没有问题.我将缓存已经渲染的公式,因此对演示文稿文档中包含的每个公式调用latex + dvisvgm应该没有问题.

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.

还要注意,我使用了预处理器(我不手工编写QML代码而是生成它).因此,对于Latex代码,我不需要QML元素,但是我可以生成带有Image元素的QML代码片段(对于第一个解决方案).这样可以简化嵌入渲染图像的过程.

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.

使用内联Latex时,我也不需要支持包装公式. (Latex在编写内联公式时会这样做,但是我只使用小的公式,无论如何我都不想将它们包装起来.)

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.

听起来您需要使公式与某些文本段落保持一致,所以出于这个原因,我认为选项2是实现此目的的好方法.

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.

使用WebKit组件并不难.我不确定您所说的太重"是什么意思.

It isn't difficult to use the WebKit component. I'm not sure what you mean by "too heavy".

干杯!

这篇关于将乳胶嵌入QML的可能性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆