Skip to content

Commit 983dd18

Browse files
committed
Allow negative dimensions for \\[] but clip to 0 since this isn't really allowed in MathML. I will need to figure out something better for the future, but for now this will prevent the error message. Issue #236.
1 parent 0ed5d46 commit 983dd18

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

unpacked/extensions/TeX/AMSmath.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
MathJax.Extension["TeX/AMSmath"] = {
25-
version: "2.0.2",
25+
version: "2.0.3",
2626

2727
number: 0, // current equation number
2828
startNumber: 0, // current starting equation number (for when equation is restarted)
@@ -41,7 +41,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
4141
STACKITEM = TEX.Stack.Item,
4242
CONFIG = TEX.config.equationNumbers;
4343

44-
var COLS = function (W) {return W.join("em ") + "em"};
44+
var COLS = function (W) {
45+
var WW = [];
46+
for (var i = 0, m = W.length; i < m; i++)
47+
{WW[i] = TEX.Parse.prototype.Em(W[i])}
48+
return WW.join(" ");
49+
};
4550

4651
/******************************************************************************/
4752

unpacked/jax/input/TeX/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
MathJax.InputJax.TeX = MathJax.InputJax({
2626
id: "TeX",
27-
version: "2.0.6",
27+
version: "2.0.7",
2828
directory: MathJax.InputJax.directory + "/TeX",
2929
extensionDir: MathJax.InputJax.extensionDir + "/TeX",
3030

unpacked/jax/input/TeX/jax.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
}
297297
if (this.rowspacing) {
298298
var rows = this.arraydef.rowspacing.split(/ /);
299-
while (rows.length < this.table.length) {rows.push(this.rowspacing)}
299+
while (rows.length < this.table.length) {rows.push(this.rowspacing+"em")}
300300
this.arraydef.rowspacing = rows.join(' ');
301301
}
302302
},
@@ -1613,7 +1613,7 @@
16131613
var n;
16141614
if (this.string.charAt(this.i) === "[") {
16151615
n = this.GetBrackets(name,"").replace(/ /g,"");
1616-
if (n && !n.match(/^(((\.\d+|\d+(\.\d*)?))(pt|em|ex|mu|mm|cm|in|pc))$/))
1616+
if (n && !n.match(/^((-?(\.\d+|\d+(\.\d*)?))(pt|em|ex|mu|mm|cm|in|pc))$/))
16171617
{TEX.Error("Bracket argument to "+name+" must be a dimension")}
16181618
}
16191619
this.Push(STACKITEM.cell().With({isCR: true, name: name, linebreak: true}));
@@ -1622,8 +1622,8 @@
16221622
if (n && top.arraydef.rowspacing) {
16231623
var rows = top.arraydef.rowspacing.split(/ /);
16241624
if (!top.rowspacing) {top.rowspacing = this.dimen2em(rows[0])}
1625-
while (rows.length < top.table.length) {rows.push(top.rowspacing)}
1626-
rows[top.table.length-1] = (top.rowspacing+this.dimen2em(n)) + "em";
1625+
while (rows.length < top.table.length) {rows.push(this.Em(top.rowspacing))}
1626+
rows[top.table.length-1] = this.Em(Math.max(0,top.rowspacing+this.dimen2em(n)));
16271627
top.arraydef.rowspacing = rows.join(' ');
16281628
}
16291629
} else {
@@ -1633,7 +1633,7 @@
16331633
},
16341634
emPerInch: 7.2,
16351635
dimen2em: function (dim) {
1636-
var match = dim.match(/^((?:\.\d+|\d+(?:\.\d*)?))(pt|em|ex|mu|pc|in|mm|cm)/);
1636+
var match = dim.match(/^(-?(?:\.\d+|\d+(?:\.\d*)?))(pt|em|ex|mu|pc|in|mm|cm)/);
16371637
var m = parseFloat(match[1]||"1"), unit = match[2];
16381638
if (unit === "em") {return m}
16391639
if (unit === "ex") {return m * .43}
@@ -1645,6 +1645,10 @@
16451645
if (unit === "mu") {return m / 18}
16461646
return 0;
16471647
},
1648+
Em: function (m) {
1649+
if (Math.abs(m) < .0006) {return "0em"}
1650+
return m.toFixed(3).replace(/\.?0+$/,"") + "em";
1651+
},
16481652

16491653
HLine: function (name,style) {
16501654
if (style == null) {style = "solid"}

0 commit comments

Comments
 (0)