New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enclosing parentheses should be equivalent to <mfenced></mfenced> tags #3208
Comments
I think you have my first edition. Sorry, I did edit my comment about 15 minutes later than the first, where there is no ] and the second example is an invalid MathML, while the third example is a valid one. I can understand that MathJax does its best to translate LaTex but, if we assume parentheses positions as XML tags have a meaning of opening tag for Perhaps another tag, other than parentheses, could do the purpose? Or restore An extract of https://www.w3.org/TR/mathml4/#presm_scrlim <msup>
<mrow>
<mo> ( </mo>
<mrow>
<mi> x </mi>
<mo> + </mo>
<mi> y </mi>
</mrow>
<mo> ) </mo>
</mrow>
<mn> 2 </mn>
</msup> » |
It looks like we may have been editing at the same time, so perhaps I did end up modifying an earlier version. The edit history shows you made two edited versions, and they all include the <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mfenced>
<mstyle displaystyle="false" scriptlevel="0">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mstyle>
</mfenced>
<msup>
<mi>n</mi>
</msup>
</mrow>
</mrow>
</mstyle>
</math> but this is not valid MathML, as I point out above. The <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mfenced>
<mstyle displaystyle="false" scriptlevel="0">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mstyle>
</mfenced>
<mi>n</mi>
</msup>
</mstyle>
</math> as I suggested above.
That is not a valid assumption. For example, some people use
Unfortunately, that's not how LaTeX works, and the difference is not just decorative. In LaTeX, parentheses entered individually do not stretch and are not paired, while those entered with
Yes, that is invalid MathML, not because of the
<msup>
<mrow>
<mo> ( </mo>
<mrow>
<mi> x </mi>
<mo> + </mo>
<mi> y </mi>
</mrow>
<mo> ) </mo>
</mrow>
<mn> 2 </mn>
</msup> Yes, that's right, and the way you would write that expression in LaTeX is <msup>
<mrow data-mjx-texclass="ORD">
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
<mo stretchy="false">)</mo>
</mrow>
<mn>2</mn>
</msup> which is in line with the example from the specification, missing only the redundant inner As you can see, you can control MathJax's MathML production by proper use of braces to indication the grouping that you intend. Because LaTeX is not semantic, If you want to create more semantically meaningful MathML, you need to be more careful about how your LaTeX is constructed, as you are the one to impose the semantics, not LaTeX (and so, not MathJax's LaTeX input jax). |
Dear you,
You are right when you say an interval may be )-3,4[ not being paired. But that is an interval, not an equation.
Turning back to the sample I gave; it is an equation:
\begin{equation} {(\tfrac{1}{2})^n} \end{equation}
Inside a math equation, clearly, parentheses should match.
Thanks for your patience.
Xavier
…________________________________
De: Davide P. Cervone ***@***.***>
Enviat el: dimarts, 26 de març de 2024 18:32
Per a: mathjax/MathJax ***@***.***>
A/c: Xavier Ramon Junqué i de Fortuny ***@***.***>; Author ***@***.***>
Tema: Re: [mathjax/MathJax] Enclosing parentheses should be equivalent to <mfenced></mfenced> tags (Issue #3208)
I think you have my first edition. Sorry, I did edit my comment about 15 minutes later than the first, where there is no ] and the second example is an invalid MathML, while the third example is a valid one.
It looks like we may have been editing at the same time, so perhaps I did end up modifying an earlier version. The edit history shows you made two edited versions, and they all include the ] and neither they nor the original have a valid third example. Your edited version seems to be
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<mrow class="MJX-TeXAtom-ORD">
<mrow class="MJX-TeXAtom-ORD">
<mfenced>
<mstyle displaystyle="false" scriptlevel="0">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mstyle>
</mfenced>
<msup>
<mi>n</mi>
</msup>
</mrow>
</mrow>
</mstyle>
</math>
but this is not valid MathML, as I point out above. The <msup> is invalid because it requires two children, not one. You would need the <msup> open tag to be before the <mfenced> open tag. That is, the <mfenced>...</mfenced> would have to be the first child of the <msup> and the <mi>n</mi> be the second, as in
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<msup>
<mfenced>
<mstyle displaystyle="false" scriptlevel="0">
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
</mstyle>
</mfenced>
<mi>n</mi>
</msup>
</mstyle>
</math>
as I suggested above.
if we assume parentheses positions as XML tags have a meaning of opening tag for <mo stretchy="false">(</mo> and closing tag for <mo stretchy="false">)</mo>
That is not a valid assumption. For example, some people use )0,1( to mean the open interval from 0 to 1, so ) is an open delimiter and ( is a close delimiter. LaTeX makes very limited semantic assumptions about the meaning of the symbols, in general, and certainly doesn't pair symbols as you are requesting. You must do that explicitly yourself, using \left and \right` which enforces the pairing. That is the mechanism that TeX provides for doing such pairing, and for MathJax to do anything else would be counter to what LaTeX does.
other than decorative, as I see it, they should have a role equivalent to that of deprecated <mfenced> </mfenced>
Unfortunately, that's not how LaTeX works, and the difference is not just decorative. In LaTeX, parentheses entered individually do not stretch and are not paired, while those entered with \left and \right do stretch and are paired. MathJax has to handle these symbols in the same way LaTeX does: parentheses given by <mo stretchy="false"> will not stretch and are not paired, while <mfenced> would have parentheses that do pair and that are paired, though the recommended encoding, as you yourself point out, would be <mrow><mo>(</mo>...<mo>)</mo></mrow>, which is what MathJax produces for \left(...\right). You are asking MathJax to make semantic interpretations of the expression that are not being done by LaTeX, and that will end up producing different output from what LaTeX would produce. LaTeX has ways to produce the MathML you are looking for, but you do have to use them if that's the MathML you want to produce.
In this case, the MathML construct is not XML valid -captured in my second example.
Yes, that is invalid MathML, not because of the <mfenced> but because of the <msup>. But that is not MathML that MathJax produces, so I'm not sure why you are complaining about it. That is your own editing of the MathML, and you have corrupted it by doing so. That is not MathJax's fault, nor something MathJax has any way to fix for you.
[From the MathML specification] For example, (x+y)^2 should be written as:
<msup>
<mrow>
<mo> ( </mo>
<mrow>
<mi> x </mi>
<mo> + </mo>
<mi> y </mi>
</mrow>
<mo> ) </mo>
</mrow>
<mn> 2 </mn>
</msup>
Yes, that's right, and the way you would write that expression in LaTeX is {(x+y)}^2, not (x+y)^2. The former means raise the entire (x+y) to the power of 2, whereas the second (in LaTeX) means raise the ) to the power 2, since LaTeX does no parentheses pairing in this case. The output from MathJa for {(x+y)}^2 is
<msup>
<mrow data-mjx-texclass="ORD">
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
<mo stretchy="false">)</mo>
</mrow>
<mn>2</mn>
</msup>
which is in line with the example from the specification, missing only the redundant inner mrow. I do not see why that have included that, but if you want an extra mrow, you could use { ( {x+y} ) }^2 to achieve that.
As you can see, you can control MathJax's MathML production by proper use of braces to indication the grouping that you intend. Because LaTeX is not semantic, If you want to create more semantically meaningful MathML, you need to be more careful about how your LaTeX is constructed, as you are the one to impose the semantics, not LaTeX (and so, not MathJax's LaTeX input jax).
—
Reply to this email directly, view it on GitHub<#3208 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGPV4V62ET6R7KSSLQ2Y6ILY2GWKRAVCNFSM6AAAAABFI437B2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGA3DEOJWGA>.
You are receiving this because you authored the thread.
|
\begin{equation} {(\tfrac{1}{2})^n} \end{equation} Actually, despite the \begin{equation} ]0,1[ \cup [1,2[ = ]0,2[ \end{equation} A naïve pairing of "open" brackets with "close" ones will be totally wrong, here. In any case, since MathJax is trying to reproduce LaTeX input and output (not some computer algebra system results), the generated MathML is not going to be changed, since that would produce results different from LaTeX. |
Dear you,
Certainly,
\begin{equation} ]0,1[ \cup [1,2[ = ]0,2[ \end{equation}
is not an equation in spite of being labeled as "equation".
Then, language suffers from a lack of precision.
It could be \begin{formula} or \begin{matching expression} or any other expressing really the concept behind.
…________________________________
De: Davide P. Cervone ***@***.***>
Enviat el: dimarts, 26 de març de 2024 20:35
Per a: mathjax/MathJax ***@***.***>
A/c: Xavier Ramon Junqué i de Fortuny ***@***.***>; Author ***@***.***>
Tema: Re: [mathjax/MathJax] Enclosing parentheses should be equivalent to <mfenced></mfenced> tags (Issue #3208)
Turning back to the sample I gave; it is an equation:
\begin{equation} {(\tfrac{1}{2})^n} \end{equation}
Actually, despite the equation environment, it is not an equation, since it has no equal sign (an equation is two expressions with an equal sign between them). This is an expression, and so is ]3,4[. You can certainly use the latter in an equation, as in
\begin{equation} ]0,1[ \cup [1,2[ = ]0,2[ \end{equation}
A naïve pairing of "open" brackets with "close" ones will be totally wrong, here.
In any case, since MathJax is trying to reproduce LaTeX input and output (not some computer algebra system results), the generated MathML is not going to be changed, since that would produce results different from LaTeX.
—
Reply to this email directly, view it on GitHub<#3208 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGPV4V47PMQVJKSQLYASWYTY2HEYFAVCNFSM6AAAAABFI437B2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGMYTEOBRGA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Certainly this is an equation, because it is an equality between two mathematical objects: it says that the open interval from 0 to 1 when union with the half-open interval from 1 (inclusive) to 2 (exclusive) is equal to the open interval from 0 to 2. That is an equality between two expressions and so it is an equation, by definition. On the other hand But none of that matters, as matching parentheses or brackets is not something that LaTeX does except when something like |
You are right saying what is and what is not equation.
There are plenty of LaTex examples out there (math expressions or equations) not considering the use of \left and \right -as you pointed- and the result is a poor or bad translation into MathML.
If LaTex can't express itself with rigor, LaTex coder has to supply this lack with extra work.
…________________________________
De: Davide P. Cervone ***@***.***>
Enviat el: dimarts, 26 de març de 2024 21:12
Per a: mathjax/MathJax ***@***.***>
A/c: Xavier Ramon Junqué i de Fortuny ***@***.***>; Author ***@***.***>
Tema: Re: [mathjax/MathJax] Enclosing parentheses should be equivalent to <mfenced></mfenced> tags (Issue #3208)
Certainly,
\begin{equation} ]0,1[ \cup [1,2[ = ]0,2[ \end{equation}
is not an equation in spite of being labeled as "equation".
Certainly this is an equation, because it is an equality between two mathematical objects: it says that the open interval from 0 to 1 when union with the half-open interval from 1 (inclusive) to 2 (exclusive) is equal to the open interval from 0 to 2. That is an equality between two expressions and so it is an equation, by definition.
On the other hand {(\tfrac{1}{2})^n} is not an equation, as it is not an equality between two expressions. It is a single expression, therefore, not an equation.
But none of that matters, as matching parentheses or brackets is not something that LaTeX does except when something like \left and \right are used. It doesn't matter if it is an equation or just an expression, as there is no way for LaTeX or MathJax to know what delimiters are supposed to me matched without your being more explicit about in your original LaTeX notation. That's just how LaTeX works, and wishing it did something else is not going to change that.
—
Reply to this email directly, view it on GitHub<#3208 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGPV4V6ATPDB3FUGWCT4F23Y2HJCBAVCNFSM6AAAAABFI437B2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRRGM3TMNRUGM>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
TeX was developed in the late 1970s as a means of producing high quality printed documents that include mathematics. That means its main focus was getting the symbols onto the page in the right locations, so its input language does not enforce any semantic meaning to the underlying symbols (the reader does that when he or she reads the page). It was not meant as an interchange language, and is not structured to carry the mathematical meaning of the symbols it presents. Presentation MathML is also meant mostly for displaying mathematics, not giving it meaning, though its tags do help give it some semantics, and certainly more than TeX does. Because TeX does not carry semantic meaning, trying to add that semantics to the MathML output means moving beyond what was in the original TeX, and that means guessing what the original semantics should be. While that can be done in some cases, there are always going to be TeX expressions were that guesswork gets it wrong. MathJax's mission is to reproduce TeX output's for any given input, not to produce the most semantically meaningful representation of the underlying mathematics (which may or may not render the same as TeX would). A MathML expression that reproduces the desired TeX output is not a "poor" or "bad" translation when that is the goal. You have a different goal, which is fine, but it is not MathJax's mission to produce the output you are looking for.
Yes, that's correct. Writing semantically meaningful LaTeX is possible, but it does take extra care to do so. Because TeX and LaTeX input isn't required to be meaningful, trying to impose meaning onto it would only work sometimes. MathJax does have a semantic-enrichment extension that tries to determine meaning for the expressions it processes. It will, for example, convert <mo stretchy="false">(</mo>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup> to <msup>
<mrow>
<mo stretchy="false">(</mo>
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
<mo stretchy="false">)</mo>
</mrow>
<mn>2</mn>
</msup> but the heuristics for this are "standard" meanings of the symbols, and so will fail in circumstances where they are not used in that standard way. For example, it will badly misinterpret the interval notation in my previous comments. But perhaps that would do what you are looking for. |
The semantic-enrichment seems interesting, thanks. Meanwhile, I have added a verification to the application I am with, to assure the correct execution.
But, today I am facing a new problem and it is not extrange because I am coding extensively and making use of MathJax.
I think I will open another issue because it is different to the current one.
…________________________________
De: Davide P. Cervone ***@***.***>
Enviat el: dimecres, 27 de març de 2024 14:48
Per a: mathjax/MathJax ***@***.***>
A/c: Xavier Ramon Junqué i de Fortuny ***@***.***>; Author ***@***.***>
Tema: Re: [mathjax/MathJax] Enclosing parentheses should be equivalent to <mfenced></mfenced> tags (Issue #3208)
There are plenty of LaTex examples out there (math expressions or equations) not considering the use of \left and \right [or braces] -as you pointed- and the result is a poor or bad translation into MathML.
TeX was developed in the late 1970s as a means of producing high quality printed documents that include mathematics. That means its main focus was getting the symbols onto the page in the right locations, so its input language does not enforce any semantic meaning to the underlying symbols (the reader does that when he or she reads the page). It was not meant as an interchange language, and is not structured to carry the mathematical meaning of the symbols it presents.
Presentation MathML is also meant mostly for displaying mathematics, not giving it meaning, though its tags do help give it some semantics, and certainly more than TeX does. Because TeX does not carry semantic meaning, trying to add that semantics to the MathML output means moving beyond what was in the original TeX, and that means guessing what the original semantics should be. While that can be done in some cases, there are always going to be TeX expressions were that guesswork gets it wrong. MathJax's mission is to reproduce TeX output's for any given input, not to produce the most semantically meaningful representation of the underlying mathematics (which may or may not render the same as TeX would). A MathML expression that reproduces the desired TeX output is not a "poor" or "bad" translation when that is the goal. You have a different goal, which is fine, but it is not MathJax's mission to produce the output you are looking for.
If LaTex can't express itself with rigor, LaTex coder has to supply this lack with extra work.
Yes, that's correct. Writing semantically meaningful LaTeX is possible, but it does take extra care to do so. Because TeX and LaTeX input isn't required to be meaningful, trying to impose meaning onto it would only work sometimes.
MathJax does have a semantic-enrichment extension that tries to determine meaning for the expressions it processes. It will, for example, convert (x+y)^2 from
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
<msup>
<mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
to
<msup>
<mrow>
<mo stretchy="false">(</mo>
<mrow>
<mi>x</mi>
<mo>+</mo>
<mi>y</mi>
</mrow>
<mo stretchy="false">)</mo>
</mrow>
<mn>2</mn>
</msup>
but the heuristics for this are "standard" meanings of the symbols, and so will fail in circumstances where they are not used in that standard way. For example, it will badly misinterpret the interval notation in my previous comments. But perhaps that would do what you are looking for.
—
Reply to this email directly, view it on GitHub<#3208 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGPV4VZZTJZ2GMGVZZYJ5XLY2LE3HAVCNFSM6AAAAABFI437B2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRSHAYTOMRYGQ>.
You are receiving this because you authored the thread.
|
To whom it may concern:
Latex code
translated by MathJax into MathML gives the following MathML code which is XML valid code, but should not as MathML code:
This is, if we replace the enclosing parentheses by a
<mfenced>
tag (which should give an equivalent valid math expression), it results an invalid XML code:The reason is because the position of the closing
</mfenced>
or<mo strechy="false">)</mo>
should be before the<msup>
tag:Thanks beforehand for your interest.
Xavier Junqué i de Fortuny
The text was updated successfully, but these errors were encountered: