<?xml version='1.0' encoding=“UTF-8”?> <xsl:stylesheet xmlns:xsl=“www.w3.org/1999/XSL/Transform

xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:inst="http://instructure.com/functions"
extension-element-prefixes="inst"
version='1.0'>
<xsl:template match="m:munder">
  <xsl:call-template name="munder">
    <xsl:with-param name="base">
      <xsl:call-template name="startspace">
        <xsl:with-param name="symbol" select="./*[1]"/>
      </xsl:call-template>
    </xsl:with-param>
    <xsl:with-param name="under">
      <xsl:call-template name="startspace">
        <xsl:with-param name="symbol" select="./*[2]"/>
      </xsl:call-template>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>
<xsl:template name="munder">
  <xsl:param name="base"/>
  <xsl:param name="under"/>
  <xsl:variable name="diacritics-regex" select="'^[&#x300;-&#x338;&#x20d0;-&#x20ef;]$'" />
  <xsl:variable name="is-diacritical-mark" select="inst:matches($under, $diacritics-regex)" />
  <!-- original: scripts.xsl line 128 -->
  <!-- modified based on: mml2tex.xsl line 312 -->
  <xsl:choose>
    <xsl:when test="translate($base,'&#x0220F;&#x02210;&#x022c2;&#x022c3;&#x02294;',
            '&#x02211;&#x02211;&#x02211;&#x02211;&#x02211;')='&#x02211;'">
  <!-- if $base is operator, such as
        &#x02211; /sum L: summation operator
        &#x0220F; /prod L: product operator
        &#x02210; /coprod L: coproduct operator
        &#x022c2; /bigcap
        &#x022c3; /bigcup
        &#x02294; /bigsqcup
  -->
      <xsl:apply-templates select="./*[1]"/>
      <xsl:text>_{</xsl:text>
      <xsl:apply-templates select="./*[2]"/>
      <xsl:text>}</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="$under = '&#x23de;' or $under = '&#x23df;'">
          <xsl:text>\underbrace</xsl:text>
        </xsl:when>
        <xsl:when test="$under = '&#x23b4;' or $under = '&#x23b5;'">
          <xsl:text>\underbracket</xsl:text>
        </xsl:when>
        <xsl:when test="inst:matches($under, '^[&#xaf;&#x5f;&#x304;&#x305;&#x203e;]$')"><!-- macron, combining macron, combining overline -->
          <xsl:text>\underline</xsl:text>
        </xsl:when>
        <xsl:when test="$is-diacritical-mark">
          <xsl:apply-templates select="./*[2]"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>\underset{</xsl:text>
          <xsl:apply-templates select="./*[2]"/>
          <xsl:text>}</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:text>{</xsl:text>
      <xsl:apply-templates select="./*[1]"/>
      <xsl:text>}</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>