From 4ef56bb0074a5db997a9830490086578376a186c Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 22 Feb 2015 10:54:33 -0500 Subject: [PATCH] Better fraction layout (works in XHTML). --- unpacked/jax/output/CommonHTML/jax.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 20f44c6f3..6b9e78516 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -87,8 +87,12 @@ "display": "inline-table!important", "text-align":"center"}, ".MJXc-mfrac > *": {"display": "table-row!important"}, ".MJXc-num": {"line-height": 0}, + ".MJXc-num > span": {"display":"inline-block"}, ".MJXc-num > *": {"line-height":"1.2", "width":"100%"}, ".MJXc-num > * > *": {"display":"table!important", "width":"100%"}, + ".MJXc-den": {"line-height":".96"}, + ".MJXc-den > *": {"display":"table-cell!important"}, + ".MJXc-den > * > *": {"line-height":"1.2"}, ".MJXc-mfrac-row": {"display":"table-row!important"}, ".MJXc-mfrac-row > *": {"display":"table-cell!important","width":"100%"}, @@ -932,24 +936,24 @@ ] ]); num.firstChild.firstChild.firstChild.appendChild(span.firstChild); - var denom = HTML.Element("span",{className:"MJXc-mfrac-row"}); + var denom = HTML.Element("span",{className:"MJXc-den"}); denom.appendChild(span.firstChild); span.appendChild(num); span.appendChild(denom); var nbox = this.CHTMLbboxFor(0), dbox = this.CHTMLbboxFor(1), bbox = this.CHTML; - bbox.w = Math.max(nbox.w,dbox.w) * .8; - bbox.h = nbox.h+nbox.d + .1 + .25; - bbox.d = dbox.h+dbox.d - .25; + if (nbox.h < .9) num.firstChild.firstChild.style.marginTop = CHTML.Em(.8*(nbox.h-.9)); + bbox.w = .8*Math.max(nbox.w,dbox.w); + bbox.h = .8*(nbox.h+nbox.d) + .25; + bbox.d = .8*(dbox.h+dbox.d) - .25; bbox.l = bbox.r = .125; values.linethickness = Math.max(0,CHTML.length2em(values.linethickness||"0",0)); if (values.linethickness) { var rule = num.firstChild.firstChild.lastChild.lastChild.lastChild; - var t = CHTML.Em(values.linethickness); - rule.style.borderTop = (values.linethickness < .15 ? "1px" : t)+" solid"; - rule.style.margin = t+" 0"; + var t = (values.linethickness < .15 ? "1px" : CHTML.Em(values.linethickness)); + rule.style.borderTop = t+" solid"; rule.style.margin = t+" 0"; t = values.linethickness; - span.style.verticalAlign = CHTML.Em(1.5*t + .1); - bbox.h += 1.5*t - .1; bbox.d += 1.5*t; + span.style.verticalAlign = CHTML.Em(.25-t); + bbox.h += 2*t; bbox.d += t; } return span; }