-
-
Notifications
You must be signed in to change notification settings - Fork 344
Description
When inserting a fraction (\frac{a}{b}) inside an array environment, the fraction is rendered with the numerator and denominator visually inverted. The numerator appears at the bottom and the denominator appears at the top.
However, when reading the LaTeX output via getValue('latex'), the output is correct (\frac{a}{b} with a as numerator). This indicates it's a rendering issue only, not a data issue.
Steps to reproduce
- Create a MathfieldElement
- Set the value to:
\begin{array}{clc}3 & \text{if} & 1<2\\ 2 & & \text{otherwise}.\end{array}
- Position cursor after the
3 - Execute:
mathField.executeCommand(['insert', '\\frac{#@}{#?}']);
- Observe the rendered output vs the LaTeX string
Expected behavior
- Visual:
3should appear above the placeholder (as numerator) - LaTeX output:
\frac{3}{\placeholder{}}✓
Actual behavior
- Visual:
3appears below the placeholder (as if it were the denominator) ✗ - LaTeX output:
\frac{3}{\placeholder{}}✓ (correct)
Console log evidence
[SmartDivision] Before insert: \begin{array}{clc}3 & \text{if} & 2<2\\ 2 & & \text{otherwise}.\end{array}
[SmartDivision] After insert: \begin{array}{clc}\frac{3}{\placeholder{}} & \text{if} & 2<2\\ 2 & & \text{otherwise}.\end{array}
The LaTeX output shows \frac{3}{\placeholder{}} which is correct (3 as numerator), but the visual rendering shows it inverted.
Environment
- MathLive version: 0.108.2
- Browser: Chrome Versión 142.0.7444.176 (Oficial build) (64 bits)
- OS: Windows 11
Impact
This bug causes confusion for users as the visual representation does not match the actual mathematical expression. While calculations based on the LaTeX output are correct, the visual feedback is misleading and can lead to user errors.
Workaround attempted
We tried inverting the order in the insert command (\frac{#?}{#@} instead of \frac{#@}{#?}) to make it display correctly, but this generates incorrect LaTeX and wrong calculations.
Additional context
This issue only occurs inside \begin{array}...\end{array} environments. Fractions inserted outside of arrays render correctly.
