我正在使用Mathjax在Jekyll网站中嵌入公式,使用Kramdown作为我的渲染器。
它工作得很漂亮,除了之外,在内联公式之后总是会插入一个隐含的单词分隔符,这意味着换行可以在公式和标点符号之间插入换行符。这导致了这样的事情:
Where this fell down was that my representation was very limited as to what
numbers it can represent. The _smallest_ number possible was the integer `1`,
which represented $$\frac{1}{64} \approx 0.016$$; the _largest_ number was
the integer `127` (the top bit is used for the sign), which represented $$1
\frac{63}{64} \approx 1.98$$.
......正如此呈现:
哪个看起来很糟糕。
有没有办法防止这种情况发生?
答案 0 :(得分:2)
在MathJax和任何降价处理器(我都不知道)中没有内置的解决方法。
接近这个的两种方法:
white-space: nowrap;
;这将确保不会出现任何中断。答案 1 :(得分:1)
使用\(...\)
分隔符进行内联数学而不是$$...$$
,并在span标记中包含整个(带有ponctuation并且没有空格)为我工作
Where this fell down was that my representation was very limited as to what
numbers it can represent. The _smallest_ number possible was the integer `1`,
which represented <span>\(\frac{1}{64} \approx 0.016\);</span> the _largest_ number was
the integer `127` (the top bit is used for the sign), which represented <span>\(1
\frac{63}{64} \approx 1.98\)..............</span>
编辑: 一个片段,说明了两个选项之间可能存在的差异(但再一次,它将取决于您的配置)
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<span>\(1
\frac{63}{64} \approx 1.98\)..............................................................</span>
<br>(which works with no white-space:nowrap)
<span style="white-space:nowrap;">$$1
\frac{63}{64} \approx 1.98$$.............................................................</span>
<br>(which doesn't work with white-space:nowrap)