Skip to content

Commit 548acb9

Browse files
committed
Make \Rule use mspace so that negative dimensions are handled; add \rule macro from LaTeX. Resolves issue #1666.
1 parent 773c2d4 commit 548acb9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

unpacked/jax/input/TeX/jax.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@
868868
mskip: 'Hskip',
869869
mspace: 'Hskip',
870870
mkern: 'Hskip',
871+
rule: 'rule',
871872
Rule: ['Rule'],
872873
Space: ['Rule','blank'],
873874

@@ -1581,12 +1582,25 @@
15811582
h = this.GetDimen(name),
15821583
d = this.GetDimen(name);
15831584
var mml, def = {width:w, height:h, depth:d};
1584-
if (style !== 'blank') {
1585-
if (parseFloat(w) && parseFloat(h)+parseFloat(d))
1586-
{def.mathbackground = (this.stack.env.color || "black")}
1587-
mml = MML.mpadded(MML.mrow()).With(def);
1588-
} else {
1589-
mml = MML.mspace().With(def);
1585+
if (style !== 'blank') def.mathbackground = (this.stack.env.color || "black");
1586+
this.Push(MML.mspace().With(def));
1587+
},
1588+
rule: function (name) {
1589+
var v = this.GetBrackets(name),
1590+
w = this.GetDimen(name),
1591+
h = this.GetDimen(name);
1592+
var mml = MML.mspace().With({
1593+
width: w, height:h,
1594+
mathbackground: (this.stack.env.color || "black")
1595+
});
1596+
if (v) {
1597+
mml = MML.mpadded(mml).With({voffset: v});
1598+
if (v.match(/^\-/)) {
1599+
mml.height = v;
1600+
mml.depth = '+' + v.substr(1);
1601+
} else {
1602+
mml.height = '+' + v;
1603+
}
15901604
}
15911605
this.Push(mml);
15921606
},

0 commit comments

Comments
 (0)