Bug 137234 - Faulty representation of integral formula { int_1^2 3 over 4 = 5}
Summary: Faulty representation of integral formula { int_1^2 3 over 4 = 5}
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Formula Editor (show other bugs)
Version:
(earliest affected)
7.0.1.2 release
Hardware: All All
: medium normal
Assignee: dante19031999
URL:
Whiteboard: target:7.1.0
Keywords:
Depends on:
Blocks: MathML
  Show dependency treegraph
 
Reported: 2020-10-03 20:56 UTC by [REDACTED]
Modified: 2023-02-15 09:27 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments
sample ODT file (9.44 KB, application/vnd.oasis.opendocument.text)
2020-10-03 20:56 UTC, [REDACTED]
Details
Faulty display of formula (2.63 KB, image/png)
2020-10-18 18:47 UTC, [REDACTED]
Details
Correct display of formula (2.57 KB, image/png)
2020-10-18 18:48 UTC, [REDACTED]
Details

Note You need to log in before you can comment on or make changes to this bug.
Description [REDACTED] 2020-10-03 20:56:25 UTC
Created attachment 166060 [details]
sample ODT file

Creating a ODT document that contains this formula ...

<?xml version='1.0' ?>
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msubsup><mo>∫</mo><mn>1</mn><mn>2</mn></msubsup><mfrac><mn>3</mn><mn>4</mn></mfrac><mo>=</mo><mn>5</mn></mrow></math>

... the representation in LibreOffice is faulty.

The formula visible is (written in the syntax as visible in LibreOffice) ...

{ int_1^2 3 over 4 = 5}

... where it should be ...

{ int_1^2 {3 over 4} = 5}

Additional detail: I created the ODT file using PanDoc, converting this LaTeX-Document into ODT:

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}

\usepackage[german]{babel}
\usepackage{a4}

\begin{document}

\[
\int_1^2 \frac{3}{4} = 5
\]

\end{document}
Comment 1 [REDACTED] 2020-10-18 18:47:32 UTC
Created attachment 166483 [details]
Faulty display of formula
Comment 2 [REDACTED] 2020-10-18 18:48:05 UTC
Created attachment 166484 [details]
Correct display of formula
Comment 3 [REDACTED] 2020-10-18 18:52:07 UTC
When opening the attached ODT file in LibreOffice 7.1.0.2 the formula looks like shown in attachment "Faulty Display of formula" (whatItIsLike.png) while it should look like shown in attachment "Correct display of formula" (whatItShouldBeLike.png)

The faulty display reads like this in LibreOffice:
{ int_1^2 3 over 4 = 5}

A correct display would read like this:
{ int_1^2 {3 over 4} = 5}
Comment 4 Rene Engelhard 2020-10-18 20:48:58 UTC
I am not actually sure.. The LaTeX code is suboptimal to begin with.

\[
\int_1^2 \frac{3}{4} = 5
\]

works by chance since it's one command and because it's an integral and one doesn't see the difference if the text is not covered by _int. Add a real big \frac or whatever and you'll see the \int will not adapt to that size because that "big thing" is not part of the \int.

a

\[
\sqrt \frac{1}{4} = \frac{1}{2}
\]

would also "work", unless you add more stuff after the fraction. You'll see that the root only covers the \frac.

Strictly speaking,

\[
\int_1^2 {\frac{3}{4}} = 5
\]

would have been correct in LaTeX even.

Your faulty display then shows that this abiguity is then followed wrong. I would assume that if you did {} the integral you would get the correct result
with bracketed { 3 over 4 }?
Comment 5 [REDACTED] 2020-10-18 21:25:52 UTC
It seems the LaTeX caused confusion instead of doing any good. Sorry for that. You may be right that the LaTeX might not be optimal.

But what if you look at the ODT file (this file might be generated with any tool, no need for LaTeX at all)

I read:

<msubsup>...</msubsup><mfrac>...</mfrac>...

I cannot see how the msubsup-section should be part of the mfrac. To me this clearly reads that i have the integral (msubsup) and then the fraction (mfrac), not the integral as part of the fraction
Comment 6 [REDACTED] 2020-10-18 21:33:55 UTC
Also, i just checked with the LaTeX:

both 

\[
\int_1^2 \frac{3}{4} = 5
\]

and

\[
\int_1^2 {\frac{3}{4}} = 5
\]

look identical in LaTeX (corresponds to whatItShouldLookLike.png) and when converted to ODT via PanDoc produce the exact same result 

<?xml version='1.0' ?>
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msubsup><mo>∫</mo><mn>1</mn><mn>2</mn></msubsup><mfrac><mn>3</mn><mn>4</mn></mfrac><mo>=</mo><mn>5</mn></mrow></math>

However ... as already mentioned i don't believe looking at LaTeX is necessary here (sorry again for the confusion), just look at the ODT file and see what LibreOffice shows.
Comment 7 [REDACTED] 2020-10-18 21:36:45 UTC
{} the integral in LaTeX does not help either, this also yields the same result:

\[
{\int_1^2} {\frac{3}{4}} = 5
\]
Comment 8 dante19031999 2020-10-21 15:26:28 UTC
Gonna see if I can create the frac command, since it seems is not the over command what should be used.
Comment 9 [REDACTED] 2020-10-22 05:53:24 UTC
"since it seems is not the over command what should be used."

Are we talkig LaTeX here? Please note again, that the whole LaTeX-thing was just provided as additional info.

My point is: look at the attached ODT-file, containing an mfrac-expression in MathML ... and look at what LibreOffice makes of it. In doubt please ignore the whole LaTeX-stuff, this was just to provide additional info in case someone would like to know how exactly i created the ODT.
Comment 10 dante19031999 2020-11-02 22:17:42 UTC
(In reply to kleinesuniversum from comment #9)
> "since it seems is not the over command what should be used."
> 
> Are we talkig LaTeX here? Please note again, that the whole LaTeX-thing was
> just provided as additional info.
> 
> My point is: look at the attached ODT-file, containing an mfrac-expression
> in MathML ... and look at what LibreOffice makes of it. In doubt please
> ignore the whole LaTeX-stuff, this was just to provide additional info in
> case someone would like to know how exactly i created the ODT.

I do get it. When you use over command will take previous token and token after. If before there is something with product priority or superior, the tokens will be made in read order, so they would go in pack and be "misplaced". It's similar to latex "a { 1 \over 2 } b" wich is different from latex "a 1 \over 2 b". That's why a \frac command is needed to solve the mathml mistake, and also improve math usability.
Comment 11 dante19031999 2020-11-04 13:41:58 UTC
This should solve it.
https://gerrit.libreoffice.org/c/core/+/105255/3
Comment 12 Commit Notification 2020-11-05 08:08:42 UTC
dante committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/d3abe0a1fb2f2b546b164280c5562443dc1f4300

Added frac command. Sould solve tdf#137234.

It will be available in 7.1.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 13 Timur 2020-11-13 07:44:28 UTC
For commenters here: you may test yourself with LO 7.1+ master from https://dev-builds.libreoffice.org/daily/master/current.html and (after some days) for Linux also from 1-file https://libreoffice.soluzioniopen.com/daily-version/.