Skip to content

Commit f2ff031

Browse files
authored
Merge pull request #999 from mathjax/issue3097
Use superscript for scriptChild in msubsup. (mathjax/MathJax#3097)
2 parents ec419a0 + 038be90 commit f2ff031

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ts/output/common/Wrappers/msubsup.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ export function CommonMsubsupMixin<
412412
return this.childNodes[(this.node as MmlMsubsup).sup];
413413
}
414414

415+
/**
416+
* @override
417+
*/
418+
public get scriptChild(): WW {
419+
return this.supChild;
420+
}
421+
415422
/**
416423
* @override
417424
*/
@@ -426,23 +433,26 @@ export function CommonMsubsupMixin<
426433
const t = 3 * tex.rule_thickness;
427434
const subscriptshift = this.length2em(this.node.attributes.get('subscriptshift'), tex.sub2);
428435
const drop = this.baseCharZero(bbox.d * this.baseScale + tex.sub_drop * subbox.rscale);
436+
const supd = supbox.d * supbox.rscale;
437+
const subh = subbox.h * subbox.rscale;
429438
//
430439
// u and v are the veritcal shifts of the scripts, initially set to minimum values and then adjusted
431440
//
432441
let [u, v] = [this.getU(), Math.max(drop, subscriptshift)];
433442
//
434443
// q is the space currently between the super- and subscripts.
435444
// If it is less than 3 rule thicknesses,
436-
// increase the subscript offset to make the space 3 rule thicknesses
445+
// Increase the subscript offset to make the space 3 rule thicknesses
437446
// If the bottom of the superscript is below 4/5 of the x-height
438447
// raise both the super- and subscripts by the difference
439448
// (make the bottom of the superscript be at 4/5 the x-height, and the
440-
// subscript 3 rule thickness below that).
449+
// subscript 3 rule thickness below that),
450+
// provided we don't move up past the original subscript position.
441451
//
442-
let q = (u - supbox.d * supbox.rscale) - (subbox.h * subbox.rscale - v);
452+
let q = (u - supd) - (subh - v);
443453
if (q < t) {
444454
v += t - q;
445-
const p = (4 / 5) * tex.x_height - (u - supbox.d * supbox.rscale);
455+
const p = (4 / 5) * tex.x_height - (u - supd);
446456
if (p > 0) {
447457
u += p;
448458
v -= p;
@@ -454,7 +464,7 @@ export function CommonMsubsupMixin<
454464
//
455465
u = Math.max(this.length2em(this.node.attributes.get('superscriptshift'), u), u);
456466
v = Math.max(this.length2em(this.node.attributes.get('subscriptshift'), v), v);
457-
q = (u - supbox.d * supbox.rscale) - (subbox.h * subbox.rscale - v);
467+
q = (u - supd) - (subh - v);
458468
this.UVQ = [u, -v, q];
459469
return this.UVQ;
460470
}

0 commit comments

Comments
 (0)