在网页中嵌入LaTeX的最佳方式是什么? [英] What is the best way to embed LaTeX in a webpage?

查看:1550
本文介绍了在网页中嵌入LaTeX的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我并没有要求将LaTeX文档转换为html。

我希望能够做的是在HTML文档中使用LaTeX数学命令,并使其在浏览器中正确显示。这可以在服务器或客户端完成。

MediaWiki可以做你正在寻找的东西。它使用Texvc( http://en.wikipedia.org/wiki/Texvc )验证(AMS)LaTeX数学表达式并将它们转换为HTML,MathML或PNG图形。听起来像你在找什么。



查看维基百科有关他们如何处理数学方程式的文章: http://en.wikipedia.org/wiki/Help:Formula 。他们还对LaTeX和各种渲染类型(PNG / MathML / HTML)的优缺点有广泛的参考。


MediaWiki使用TeX标记的子集,
包括LaTeX
和AMS-LaTeX的一些扩展,用于数学
公式。它根据用户的偏好以及表达式的
复杂度生成PNG
图像或简单HTML标记,
。在
未来,随着更多浏览器变得更加智能,
将能够在许多情况下生成增强的
HTML甚至MathML。
(有关
当前加入MathML
支持的工作信息,请参见blahtex)。更准确地说,MediaWiki将
通过Texvc标记,反过来
将命令传递给TeX进行
的实际渲染。因此,整个TeX语言只有
部分是
支持的;详情见下文。
...



HTML的优点




  • 联机HTML公式始终与HTML
    文本的其余部分保持一致。

  • 公式的背景,字体大小和面部匹配HTML
    内容的剩余部分和外观尊重
    CSS和浏览器设置。

  • 使用HTML的页面加载速度更快。 TeX的优点


    • TeX在语义上优于HTML。在TeX中,x表示
      数学变量x,而在
      中,HTMLx可以表示任何内容。
      信息已经不可挽回地丢失。
      这有多种好处:


      1. TeX可以转换为HTML,但反之亦然。这意味着在
        服务器端,我们可以随时根据
        复杂度和
        文本中的位置,用户首选项,
        浏览器类型等等。因此,在
        可能的情况下,HTML的所有好处都可以保留
        ,以及TeX的
        好​​处。确实,
        目前的情况并不理想,但
        不是一个很好的理由放弃
        信息/内容。
      2. TeX可以转换为支持它的浏览器的MathML,因此
        保留其语义并允许它
        被渲染为一个矢量。


    • TeX专门为排版公式设计,所以输入是
      更简单,更自然,输出更美观。
    • 在TeX中编写代码时,编辑者不必担心浏览器的支持,因为
      会被渲染成图像
      服务器。在其他
      手中,HTML公式可能最终导致编辑意图
      (或根本没有),某些浏览器或
      旧版浏览器的
      不一致。



I'm not asking about converting a LaTeX document to html.

What I'd like to be able to do is have some way to use LaTeX math commands in an html document, and have it appear correctly in a browser. This could be done server or client side.

解决方案

MediaWiki can do what you are looking for. It uses Texvc (http://en.wikipedia.org/wiki/Texvc) which "validates (AMS) LaTeX mathematical expressions and converts them to HTML, MathML, or PNG graphics." Sounds like what you are looking for.

Check out Wikipedia's article on how they handle math equations here: http://en.wikipedia.org/wiki/Help:Formula. They also have an extensive reference on LaTeX and pros/cons of the different rendering types (PNG/MathML/HTML).

MediaWiki uses a subset of TeX markup, including some extensions from LaTeX and AMS-LaTeX, for mathematical formulae. It generates either PNG images or simple HTML markup, depending on user preferences and the complexity of the expression. In the future, as more browsers are smarter, it will be able to generate enhanced HTML or even MathML in many cases. (See blahtex for information about current work on adding MathML support.)

More precisely, MediaWiki filters the markup through Texvc, which in turn passes the commands to TeX for the actual rendering. Thus, only a limited part of the full TeX language is supported; see below for details. ...

Pros of HTML

  • In-line HTML formulae always align properly with the rest of the HTML text.
  • The formula's background, font size and face match the rest of HTML contents and the appearance respects CSS and browser settings.
  • Pages using HTML will load faster.

Pros of TeX

  • TeX is semantically superior to HTML. In TeX, "x" means "mathematical variable x", whereas in HTML "x" could mean anything. Information has been irrevocably lost. This has multiple benefits:

    1. TeX can be transformed into HTML, but not vice-versa. This means that on the server side we can always transform a formula, based on its complexity and location within the text, user preferences, type of browser, etc. Therefore, where possible, all the benefits of HTML can be retained, together with the benefits of TeX. It's true that the current situation is not ideal, but that's not a good reason to drop information/contents. It's more a reason to help improve the situation.
    2. TeX can be converted to MathML for browsers which support it, thus keeping its semantics and allowing it to be rendered as a vector.

  • TeX has been specifically designed for typesetting formulae, so input is easier and more natural, and output is more aesthetically pleasing.
  • When writing in TeX, editors need not worry about browser support, since it is rendered into an image by the server. HTML formulae, on the other hand, can end up being rendered inconsistent of editor's intentions (or not at all), by some browsers or older versions of a browser.

这篇关于在网页中嵌入LaTeX的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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