MathJax自动换行

Mat*_*der 4 html css mathjax ios

我已使用以下代码为MathJax配置了额外的处理

<script type="text/x-mathjax-config">

    MathJax.Hub.Config({
    tex2jax: { inlineMath: [["$","$"],["\\(","\\)"]] },
    "HTML-CSS": {
       linebreaks: { width: "container" }          
    }              
    });

</script>
Run Code Online (Sandbox Code Playgroud)

我认为它必须使用我的HTML代码中的自动换行容器.

我有这个用word-wrap设置的CSS

.col {
        background: #f0f0f0; 
        width: 230px; 
        padding: 10px; 
        font-size: 1.5em; 
        word-wrap: break-word; 
    }    
Run Code Online (Sandbox Code Playgroud)

这是我的身体:

<body>

        <div class = 'col'>

        $$
           Pr [( G \bigcup B \bigcup S)^e ] = 1 - Pr ( G \bigcup B \bigcup S)                
           = 1 - [Pr(G)+Pr(B)Pr(S)-Pr(G \bigcap B) - Pr(G \bigcap S) - Pr(B \bigcap S)]
           Pr [( G \bigcup B \bigcup S)^e ] = 1 - Pr ( G \bigcup B \bigcup S)
           = 1 - [Pr(G)+Pr(B)Pr(S)-Pr(G \bigcap B) - Pr(G \bigcap S) - Pr(B \bigcap S)]
           = 1 - (0.28 + 0.29 + 0.19 - 0.14 - 0.10 -0.12 + 0.08) = 1 - 0.48 = 0.52
        $$

        </div>

</body>
Run Code Online (Sandbox Code Playgroud)

但在我的情况下,自动换行不起作用.

我已经在iPad上附上了Safri的截图

在此输入图像描述

单词必须包装到第二行,但它们不是你可以看到的广告.

Pet*_*ger 6

编辑如果你在iOS6上,那么你可能会遇到这个MathJax错误.

MathJax使用自己的换行算法(实现MathML规范).设置word-wrap: break-word;不会改变其行为.

除非缺少某些信息,否则您的代码将按预期工作,即MathJax执行其换行.

这是一个完整的例子.

<!doctype HTML>
<head>
<title>Break!</title>
<script type="text/x-mathjax-config">

MathJax.Hub.Config({
tex2jax: { inlineMath: [["$","$"],["\\(","\\)"]] },
"HTML-CSS": {
  linebreaks: { automatic: true, width: "container" }          
}              
});

</script>
<script type="text/javascript"
  src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<style>
.col {
    background: #f0f0f0; 
    width: 230px; 
    padding: 10px; 
    font-size: 1.5em; 
    word-wrap: break-word; 
}  
</style>

</head>
<body>

    <div class = 'col'>

    $$
      Pr [( G \bigcup B \bigcup S)^e ] = 1 - Pr ( G \bigcup B \bigcup S)                
      = 1 - [Pr(G)+Pr(B)Pr(S)-Pr(G \bigcap B) - Pr(G \bigcap S) - Pr(B \bigcap S)]
      Pr [( G \bigcup B \bigcup S)^e ] = 1 - Pr ( G \bigcup B \bigcup S)
      = 1 - [Pr(G)+Pr(B)Pr(S)-Pr(G \bigcap B) - Pr(G \bigcap S) - Pr(B \bigcap S)]
      = 1 - (0.28 + 0.29 + 0.19 - 0.14 - 0.10 -0.12 + 0.08) = 1 - 0.48 = 0.52
    $$

    </div>

</body>
Run Code Online (Sandbox Code Playgroud)