Skip to content

Commit

Permalink
fix(math): Change under/over constructs' inheritance of the base atom…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
Omikhleia authored and Didier Willis committed Nov 30, 2024
1 parent bfd41c0 commit 70d4f69
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/math/base-elements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,25 @@ local function isNotEmpty (element)
return element and (element:is_a(elements.terminal) or #element.children > 0)
end

local function unwrapSingleElementMrow (elt)
-- CODE SMELL.
-- For \overset or \underset in LaTeX, MathML would use <mover> or <munder>.
-- It would need to inherit the base's atom type, especially if the later is an operator
-- (binary, relational etc.), which is a fairly common case, e.g.
-- \overset{R}{=} (equality with a R above the equal in some Ramanujan summations),
-- but we can't remove 1-element mrow's in the math typesetter, or have them inherit
-- their base's atom type here above, because it breaks tables for some reasons
-- that I couldn't figure out.
if elt:is_a(elements.stackbox) and elt.direction == "H" and #elt.children == 1 then
return unwrapSingleElementMrow(elt.children[1])
else
return elt
end
end

function elements.underOver:_init (base, sub, sup)
elements.mbox._init(self)
base = unwrapSingleElementMrow(base)
self.atom = base.atom
self.base = base
self.sub = isNotEmpty(sub) and sub or nil
Expand Down

0 comments on commit 70d4f69

Please sign in to comment.