Reputation: 13691
I'm using Mathjax to embed formulae in a Jekyll site, using Kramdown as my renderer.
It's working beautifully, except that an implicit word break is always inserted after an inline formula, which means that line wrapping can insert a line break between the formula and the punctuation. This leads to things like this:
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$$.
...being rendered as this:
Which looks terrible.
Is there any way to prevent this from happening?
Upvotes: 6
Views: 882
Reputation: 2886
Use \(...\)
delimiters for in-line mathematics instead of $$...$$
and wrap the whole (with ponctuation and no space) in a span tag works for me
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>
Edit : a snippet which illustrates the difference you may have between the two options (but once again, it will depend on your config)
<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)
Upvotes: 2
Reputation: 5285
There's no built-in way of working around this in MathJax nor in any markdown processor (that I'm aware of).
Two ways of approaching this:
white-space: nowrap;
; this will ensure that no breaks appear within.Upvotes: 4