We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
我之前曾多次使用过 dvipng 路线,但是是在 python 中。这是一条常见的道路,很多人都走过了。这是代码,可以为您提供一些入门知识,以防万一有人想要 Python 代码。 我确实意识到您要求使用 C/C++;这是针对初学者或其他人的。这是为了生成方程,但将其调整为更通用的结构是微不足道的。它确实支持包。
在透明地整合方面,我感受到你的痛苦。当然,并不是每个人都有 tex/latex,如果没有,通常很难获得。我认为,最好的方法是将该功能作为 Web 服务提供 - 但当然这并不总是一种选择。
最后,记下 dvipng 的所有选项。它们通过各种抗锯齿选项等控制外观。我对它们进行了广泛的调整,以获得我认为看起来不错的效果。
I've used the dvipng route several times before, but in python. It's a common path, that lots of people have taken. Here's the code, to give you something to get started, and in case anyone wants Python code. I do realise you asked for C/C++; this is for a starter, or for others. This is for generating equations, but it would be trivial to adapt it for more general structures. It does support packages.
In terms of integrating it transparently, I feel your pain. Not everyone has tex / latex of course, and if they don't, it's often a pain to get. The best way to do it, I think, is to provide that functionality as a web service - but of course that's not always an option.
Finally, note all the options for dvipng. They control the appearance, via various anti-alisaing options etc. I tuned them extensively to get what I thought looked good.
如果您想将部分代码转换为 png 文件,而不一定是全部,请查看 预览包.根据他们的 README,它可以提取部分内容Latex 源文件来分隔 dvi 文件,并且这些文件可以转换为 png 文件。不使用 dvipng 获取 PNG 的另一种选择是将生成的 PDF/ps 文件直接转换为 PNG:
If you want to convert parts of your code to png files, and not necessarily everything, have a look at the preview package. As per their README, it can extract parts of a Latex source file to separate dvi files, and those can be converted to png files. Another option instead of using dvipng to get PNGs would be to convert the generated PDF/ps files to PNG directly: