Skip to content

Commit 70d4f69

Browse files
OmikhleiaDidier Willis
authored andcommitted
fix(math): Change under/over constructs' inheritance of the base atom type
1 parent bfd41c0 commit 70d4f69

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/math/base-elements.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,25 @@ local function isNotEmpty (element)
732732
return element and (element:is_a(elements.terminal) or #element.children > 0)
733733
end
734734

735+
local function unwrapSingleElementMrow (elt)
736+
-- CODE SMELL.
737+
-- For \overset or \underset in LaTeX, MathML would use <mover> or <munder>.
738+
-- It would need to inherit the base's atom type, especially if the later is an operator
739+
-- (binary, relational etc.), which is a fairly common case, e.g.
740+
-- \overset{R}{=} (equality with a R above the equal in some Ramanujan summations),
741+
-- but we can't remove 1-element mrow's in the math typesetter, or have them inherit
742+
-- their base's atom type here above, because it breaks tables for some reasons
743+
-- that I couldn't figure out.
744+
if elt:is_a(elements.stackbox) and elt.direction == "H" and #elt.children == 1 then
745+
return unwrapSingleElementMrow(elt.children[1])
746+
else
747+
return elt
748+
end
749+
end
750+
735751
function elements.underOver:_init (base, sub, sup)
736752
elements.mbox._init(self)
753+
base = unwrapSingleElementMrow(base)
737754
self.atom = base.atom
738755
self.base = base
739756
self.sub = isNotEmpty(sub) and sub or nil

0 commit comments

Comments
 (0)