Implements \mathchoice command (#969)

This PR implements `\mathchoice` function.
I once created PR on the wrong branch. Sorry for the mess.

This is particularly useful when one defines custom macro for "big operators".
For example:

```latex
\newcommand{\infdisj}{%
  \mathop{%
    \mathchoice{% display
      \bigvee\hspace{-2ex}\bigvee%
    }{          % inline
      \bigvee\hspace{-1.75ex}\bigvee%
    }{          % script
      \bigvee\hspace{-1.4ex}\bigvee%
    }{          % scriptscript
      \bigvee\hspace{-1ex}\bigvee%
}}}
```
This commit is contained in:
Hiromi Ishii
2017-11-22 21:34:05 +09:00
committed by Erik Demaine
parent 2d32263998
commit 6f1661f7da
8 changed files with 245 additions and 0 deletions

View File

@@ -74,6 +74,149 @@ exports[`A MathML builder should make prime operators into <mo> nodes 1`] = `
`;
exports[`A MathML builder should render mathchoice as if there was nothing 1`] = `
<math>
<semantics>
<mrow>
<mstyle scriptlevel="0"
displaystyle="true"
>
<mrow>
<munderover>
<mo>
</mo>
<mrow>
<mi>
k
</mi>
<mo>
=
</mo>
<mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</munderover>
<msup>
<mi>
x
</mi>
<mi>
k
</mi>
</msup>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">
\\displaystyle\\mathchoice{\\sum_{k = 0}^{\\infty} x^k}{T}{S}{SS}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 2`] = `
<math>
<semantics>
<mrow>
<mrow>
<msubsup>
<mo>
</mo>
<mrow>
<mi>
k
</mi>
<mo>
=
</mo>
<mn>
0
</mn>
</mrow>
<mi mathvariant="normal">
</mi>
</msubsup>
<msup>
<mi>
x
</mi>
<mi>
k
</mi>
</msup>
</mrow>
</mrow>
<annotation encoding="application/x-tex">
\\mathchoice{D}{\\sum_{k = 0}^{\\infty} x^k}{S}{SS}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 3`] = `
<math>
<semantics>
<mrow>
<msub>
<mi>
x
</mi>
<mrow>
<mi>
T
</mi>
</mrow>
</msub>
</mrow>
<annotation encoding="application/x-tex">
x_{\\mathchoice{D}{T}{\\sum_{k = 0}^{\\infty} x^k}{SS}}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should render mathchoice as if there was nothing 4`] = `
<math>
<semantics>
<mrow>
<msub>
<mi>
x
</mi>
<msub>
<mi>
y
</mi>
<mrow>
<mi>
T
</mi>
</mrow>
</msub>
</msub>
</mrow>
<annotation encoding="application/x-tex">
x_{y_{\\mathchoice{D}{T}{S}{\\sum_{k = 0}^{\\infty} x^k}}}
</annotation>
</semantics>
</math>
`;
exports[`A MathML builder should use <menclose> for colorbox 1`] = `
<math>