Skip to content

Fractions inside array environments are rendered with numerator and denominator visually swapped #2928

@matiasdalessiodw

Description

@matiasdalessiodw

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

  1. Create a MathfieldElement
  2. Set the value to:
    \begin{array}{clc}3 & \text{if} & 1<2\\ 2 & & \text{otherwise}.\end{array}
  3. Position cursor after the 3
  4. Execute:
    mathField.executeCommand(['insert', '\\frac{#@}{#?}']);
  5. Observe the rendered output vs the LaTeX string

Expected behavior

  • Visual: 3 should appear above the placeholder (as numerator)
  • LaTeX output: \frac{3}{\placeholder{}}

Actual behavior

  • Visual: 3 appears 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.

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions