You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MathJax行内公式后自动换行问题求助

Fixing Inline MathJax Line Break Issue in Jekyll/Kramdown

Ah, I’ve run into this exact problem before! The root cause here is that double dollar signs ($$...$$) are Kramdown’s default delimiter for block-level (display) math equations, which get rendered as separate, block elements—hence the unwanted line break after your formula. Here are two simple fixes:

The standard way to write inline math with MathJax/Kramdown is using single dollar signs ($...$). Just replace your double dollars with singles in the text:

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$.

This will render the formulas inline, flowing naturally with the surrounding text and keeping the punctuation attached.

2. Reconfigure Kramdown to Use $$ for Inline Math

If you prefer to keep using double dollars (e.g., to avoid conflicts with literal dollar signs in your content), you can adjust Kramdown’s settings in your _config.yml file. Add or modify the kramdown section to explicitly set $$ as the inline math delimiter:

kramdown:
  math_engine: mathjax
  inline_math: [['$$', '$$']]

This tells Kramdown to treat $$...$$ as inline elements instead of block-level equations. Your original code will work as expected without any changes to the formula syntax.

Either approach should resolve the line break issue and make your text flow properly.

内容的提问来源于stack exchange,提问作者David Given

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:51:10