This commit addresses three issues with math rendering:
1. Large operator limits positioning (continued from previous commit)
Modified makeLargeOp() and addLimitsToDisplay() to show limits above/below
in both display and text (inline) modes:
- Changed: op.limits && style == .display
- To: op.limits && (style == .display || style == .text)
This enables operators like \lim, \sum, and \prod to show subscripts/
superscripts above and below even in inline mode \(...\), not just in
display mode \[...\].
2. Fraction font size issue
Fixed fractions appearing too small in inline mode. Previously, fractions
used one style level smaller than their parent (standard LaTeX behavior):
- Display mode → fractions use text style (acceptable)
- Text mode →
Root cause:
Inline delimiters \(...\) insert \textstyle, forcing text mode. In text
mode, fractionStyle() returned style.inc(), making numerator/denominator
use script style (two levels smaller than display). This made fraction
numbers tiny compared to surrounding text in expressions like:
\(\frac{a}{b} = c\) - a, b were script-sized while c was text-sized
Solution:
Modified fractionStyle() to return the SAME style instead of incrementing:
func fractionStyle() -> MTLineStyle {
return style // Was: return style.inc()
}
This keeps fraction numerators/denominators at the same font size as
regular text, preventing them from becoming too small. Spacing and
positioning (numeratorShiftUp, etc.) still vary by parent style.
3. Non-regression fixes
Updated test expectations to match new fraction sizing behavior
Add display-style (dfrac) and text-style (tfrac) fraction commands
to SwiftMath's LaTeX parser. These commands force fractions to render
in specific styles regardless of context.
Implementation:
- Add dfrac parsing to prepend displaystyle to numerator/denominator
- Add tfrac parsing to prepend textstyle to numerator/denominator
- Implement in both parser functions in MTMathListBuilder.swift
Testing:
- Add testDisplayStyleFraction() for dfrac validation
- Add testTextStyleFraction() for tfrac validation
- Add testDisplayAndTextStyleFractions() for complex expressions
- All 180 tests pass on macOS and iOS simulator
Documentation:
- Update MISSING_FEATURES.md (7/12 features now implemented, 58%)
- Update README.md feature list to include dfrac and tfrac
Fixes issue where equations like y'=-\dfrac{2}{x^{3}} would fail to
parse with "Invalid command dfrac" error. This was blocking the
StepByStep feature preview rendering.