MathJax自动换行不起作用 [英] MathJax automatic line breaking not working

查看:90
本文介绍了MathJax自动换行不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MathJax在我的网页上显示Math.这是我加载和配置它的方式:

I am using MathJax to display Math in my web page. This is how I load and configure it:

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
      processEscapes: true
    },
    "HTML-CSS": { fonts: ["TeX"], linebreaks: { automatic: true } }
  });
</script>
<script src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>

该脚本被放置为< body> 中的最后一个条目.在此之前,我有一些(长)数学方程式:

That script is placed as last entry inside <body>. Before it, I have some (long) math equation like:

<body>
$$
    a + b + c + d + \int_a^b f(x)dx - \sum_k c_k\int g(x)dx = \prod_n \int_{\Omega_k} F(x,y,z) d\omega
$$ 
...

问题

当我加载页面时,它使方程很好.但是,当我将页面大小设置为非常狭窄并刷新/加载页面时;该方程式无法以适合页面的方式呈现.

Problem

When I load the page, it renders the equation fine. However, when I set the page size to be very narrow and refresh/load the page; the equation is not rendered in a way to fit the page.

MathJax文档指出: linebreaks:{automatic:true} 可用于自动中断长表达式.为什么这行不通?

The MathJax doc states that linebreaks: { automatic: true } can be used to automatically break long expressions. Why isn't this working?

实时演示:我已经发布了 CodePen演示.

我也发现了类似的问题,例如此问题.那里的CodePen有效,我不明白为什么我的代码不起作用.

I have also found similar issues like in this question. The CodePen there works, I do not understand why my code does not work.

推荐答案

问题源于以下事实:内联配置与随MathJax(通过查询字符串)一起加载的组合配置文件不一致.

The problem stems from the fact that your inline configuration is at odds with the combined configuration file loaded alongside MathJax (via the query string).

内联,您正在为HTML-CSS输出设置自动换行符.但是,组合的配置文件将加载CommonHTML输出.

Inline, you're setting up the HTML-CSS output alongside automatic linebreaking for it. However, the combined configuration file loads the CommonHTML output.

对配置的最后一次更新来自组合的配置文件,因此最终得到CommonHTML输出(可以通过MathJax上下文菜单进行检查,还可以在那里切换到HTML-CSS-注意:这将设置一个cookie).

The last update to the configuration comes from the combined configuration file, so you end up with the CommonHTML output (you can check this via the MathJax context menu and also switch to HTML-CSS there -- NB: this sets a cookie).

因此,您可以更新内联配置或切换组合配置.

So you can either update your inline configuration or switch the combined configuration.

我建议使用CommonHTML输出,该输出比现在肯定古老的HTML-CSS输出(在IE8新时设计的)更新和更快.如果您知道将要渲染的内容,也可以在查询字符串中添加 -full 以获取更大的有效负载(否则MathJax在加载更多组件之前会先查找内容).

I'd suggest using the CommonHTML output which is newer and faster than the now positively ancient HTML-CSS output (which was designed when IE8 was new). You can also add -full to the query string to get a larger payload if you know you'll have content to render (otherwise MathJax first looks for content before loading more components).

body { width: 10em}

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
      processEscapes: true
    },
    "CommonHTML": { linebreaks: { automatic: true } }
  });
</script>
<script src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>

$$
    a + b + c + d + \int_a^b f(x)dx - \sum_k c_k\int g(x)dx = \prod_n \int_{\Omega_k} F(x,y,z) d\omega
$$ 

这篇关于MathJax自动换行不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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