Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use superscript for scriptChild in msubsup. (mathjax/MathJax#3097) #999

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ts/output/common/Wrappers/msubsup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ export function CommonMsubsupMixin<
return this.childNodes[(this.node as MmlMsubsup).sup];
}

/**
* @override
*/
public get scriptChild(): WW {
return this.supChild;
}

/**
* @override
*/
Expand All @@ -426,23 +433,26 @@ export function CommonMsubsupMixin<
const t = 3 * tex.rule_thickness;
const subscriptshift = this.length2em(this.node.attributes.get('subscriptshift'), tex.sub2);
const drop = this.baseCharZero(bbox.d * this.baseScale + tex.sub_drop * subbox.rscale);
const supd = supbox.d * supbox.rscale;
const subh = subbox.h * subbox.rscale;
//
// u and v are the veritcal shifts of the scripts, initially set to minimum values and then adjusted
//
let [u, v] = [this.getU(), Math.max(drop, subscriptshift)];
//
// q is the space currently between the super- and subscripts.
// If it is less than 3 rule thicknesses,
// increase the subscript offset to make the space 3 rule thicknesses
// Increase the subscript offset to make the space 3 rule thicknesses
// If the bottom of the superscript is below 4/5 of the x-height
// raise both the super- and subscripts by the difference
// (make the bottom of the superscript be at 4/5 the x-height, and the
// subscript 3 rule thickness below that).
// subscript 3 rule thickness below that),
// provided we don't move up past the original subscript position.
//
let q = (u - supbox.d * supbox.rscale) - (subbox.h * subbox.rscale - v);
let q = (u - supd) - (subh - v);
if (q < t) {
v += t - q;
const p = (4 / 5) * tex.x_height - (u - supbox.d * supbox.rscale);
const p = (4 / 5) * tex.x_height - (u - supd);
if (p > 0) {
u += p;
v -= p;
Expand All @@ -454,7 +464,7 @@ export function CommonMsubsupMixin<
//
u = Math.max(this.length2em(this.node.attributes.get('superscriptshift'), u), u);
v = Math.max(this.length2em(this.node.attributes.get('subscriptshift'), v), v);
q = (u - supbox.d * supbox.rscale) - (subbox.h * subbox.rscale - v);
q = (u - supd) - (subh - v);
this.UVQ = [u, -v, q];
return this.UVQ;
}
Expand Down