On Wed, Mar 14, 2007 at 11:12:50AM +0100, Jean-Marc Lasgouttes wrote: > >>>>> "Enrico" == Enrico Forestieri <[EMAIL PROTECTED]> writes: > > Enrico> Maybe LyX displaces too much super and subscripts, such that > Enrico> \left and \right delimiters are higher than necessary. I > Enrico> really don't care, but does the attached patch give a less > Enrico> uglier aspect in those cases? BTW, I think that with this > Enrico> patch the aspect on screen is closer to the dvi output. > > I think that for subscripts, it is the baseline that should be aligned > with the top of the nucleus. Currently mathed aligns the bottom of the > character with the top of the nucleus.
I think that you meant superscripts here. However, I don't think so. For example, if you look at how $a^2A^2$ looks like when typeset by TeX, you will notice that the rule you suggest is not followed as the 2's have their baseline aligned independently of the top of the nucleus. I couldn't find in the TeXbook an exact description of the rules followed by TeX, apart the fact that script alignment depends on the style (display, text, or script style, and even "cramped" versions of those!). I think that LyX is doing the right thing here, apart the fact that the scripts are placed either too high or too low with respect to the baseline of the nucleus. The adopted rule tries to avoid overlapping, but results in an ugly appearance. I had a closer look at it and think that the attached patch produces formulas that look better on screen. I didn't succeed in finding a case in which overlapping occurs. I found that it can occur when the nucleus is empty but even in this case the overlapping is minimal. The main difference wrt the previous patch is that the \limits type scripts are now taken into account. Any objections to applying it? -- Enrico
Index: src/mathed/InsetMathScript.C =================================================================== --- src/mathed/InsetMathScript.C (revision 17442) +++ src/mathed/InsetMathScript.C (working copy) @@ -155,7 +155,7 @@ int InsetMathScript::dy0() const if (hasLimits()) des += nd + 2; else - des = max(des, nd); + des = (3 * des) / 4; return des; } @@ -169,7 +169,7 @@ int InsetMathScript::dy1() const if (hasLimits()) asc += na + 2; else - asc = max(asc, na); + asc = (3 * na) / 4; asc = max(asc, 5); return asc; } @@ -235,8 +235,18 @@ bool InsetMathScript::metrics(MetricsInf dim.wid = max(dim.wid, down().width()); dim.wid += nwid(); } - dim.asc = dy1() + (hasUp() ? up().ascent() : 0); - dim.des = dy0() + (hasDown() ? down().descent() : 0); + int na = nasc(); + if (hasUp()) { + int asc = dy1() + up().ascent(); + dim.asc = max(na, asc); + } else + dim.asc = na; + int nd = ndes(); + if (hasDown()) { + int des = dy0() + down().descent(); + dim.des = max(nd, des); + } else + dim.des = nd; metricsMarkers(dim); if (dim_ == dim) return false;