Repository navigation
Fix underbrace, subscript '+' and '-', and 'nitalic dn_i' - #304
Conversation
jgm
left a comment
There was a problem hiding this comment.
Have you checked cases like \overbrace{a}+b or \underbrace{x}_{a}^2?
Also \frac{a}{-}?
| isPlusMinusSign :: Exp -> Bool | ||
| isPlusMinusSign e = | ||
| case e of | ||
| ESymbol _ s -> s `elem` ["+", "-", "−"] |
There was a problem hiding this comment.
s == "+" || s == "-" || etc.
is better because it avoids construction of a list.
There was a problem hiding this comment.
changed as suggested!
| "↑" -> " uparrow " | ||
| "↓" -> " downarrow " | ||
| "↦" -> " mapsto " | ||
| "\8230 " -> " dotslow " |
There was a problem hiding this comment.
Why is this here (with extra space)?
There was a problem hiding this comment.
no good reason. removed the extra space after \8230 (…)
| @@ -217,9 +217,10 @@ renderExpsIn dt ctx exps = do | |||
| if startsWithInfixNeedingLhs exps | |||
| then "{} " <> T.stripStart merged | |||
There was a problem hiding this comment.
for symmetry should the space after {} be removed? (cf. what happens on rhs)
There was a problem hiding this comment.
yes, i made this change too.
Supply empty labels for bare braces, preserve centered scripts around annotated braces, and add missing operands to standalone operators in fractions. Use explicit sign comparisons, make empty-operand spacing consistent, and remove the trailing-space ellipsis mapping. Add nine regression tests. All 3,180 tests pass; visually checked 16 LibreOffice renderings against LaTeX.
|
here's a comparison PDF showing how LO renders a few curly cases |
I also added some more test cases for these things. The |
| pure $ "{" <> base' <> " " <> under' <> "}" | ||
| under' <- renderScriptArg dt ctx under | ||
| pure $ base' <> " csub " <> centerScriptArg under' |
There was a problem hiding this comment.
Here we lose the {..} that the original put around this expression. Might this cause problems?
There was a problem hiding this comment.
I think not. LibreOffice parses csub’s argument as a single term, and {a} explicitly terminates that term. Super/subscripts bind more tightly than product/sum operators, so subsequent terms cannot be absorbed into the label. Relevant code in the starmath parser: https://github.com/LibreOffice/core/blob/libreoffice-26.2.6.3/starmath/source/parse5.cxx#L1347-L1449
|
while looking into this i found a deeper error/bug, which goes beyond the Starmath writer. I wanted to bring it specifically to your attention: Latex input: Current incorrect Starmath output: Correct Starmath output: This is actually a reader bug, so it's going to affect all other output formats as well. Similar things happen for powers. Latex doesn't automatically group sub/superscript digits together; only the first token, if ungrouped, ends up as the sub/superscript in Latex. |
|
Good -- can you split the TeX reader fix into a separate PR? |
|
Can you rebase against current master, so we just have one clean commit? |
Group annotated braces to preserve expression boundaries, supply labels for bare braces, and retain scripts on the opposite side of a brace. Supply missing operands for trailing signs and standalone operators in fractions, and separate upright letters from following identifiers. Reuse existing groups in roots, scripts, accents, and brace labels to avoid redundant braces. Add regression coverage and update golden tests for display and inline output. Consolidates the StarMath changes from jgm#304 on current master; the TeX numeric-script reader fix is already included upstream via jgm#306.
1e4df7e to
4b128f4
Compare
|
hopefully i did that right... |
|
Great! |
I found that the current starmath conversion of the following equation was causing bad starmath syntax to be output. The result was bizarre LibreOffice behaviour, nearly a crash but not quite -- basically no active rendering in the main Impress pane any more. The issue was related to the implementation of the \underbrace translation in texmath, which is fixed in this PR. Hopefully I updated to the main repository status first, please advise if not.
Correct rendering in LO after applying the patch:

Edit I've corrected a second issue here also now:
This incorrectly converted to
which renders with an error. Corrected, it now becomes:
Edit 2
Another glitch comes from this equation fragment:
which rendered incorrectly as
This needed to be changed to