Skip to content
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

Round trip conversion leads to invalid LaTeX #59

Closed
Smurf-IV opened this issue Sep 13, 2019 · 4 comments
Closed

Round trip conversion leads to invalid LaTeX #59

Smurf-IV opened this issue Sep 13, 2019 · 4 comments
Labels
Resolution/Fixed The described issue is fixed. Type/Bug

Comments

@Smurf-IV
Copy link

Describe the bug

With the correct fix from #57, still get incorrect LaTeX

To Reproduce

  • Input is \mathrm{Gap}^2
    image

  • output from MathListBuilder.MathListToString(mathList)
    is \mathrm{Gap^2}

  • Put this into the MathListBuilder -> Build() and it does not convert.

@Smurf-IV
Copy link
Author

Also makes a mess of the following
\mathrm{Gap}^2\mathrm{gb} into \mathrm{Gap^2gb}
which removes the "understanding" of this being 2 variables !

Happypig375 added a commit that referenced this issue Sep 13, 2019
@charlesroddie
Copy link
Collaborator

charlesroddie commented Sep 13, 2019

It's possible this could be changed. Ideally before that, the purpose of getting a latex string from a mathlist should be decided.

Without speccing this out I do not see a bug here. TeX represents displayed mathematics. It does not necessarily represent what formulas mean. (For example a(b+c) could refer to multiplication or function application.) In your examples the input and the output TeX will be displayed the same way. So the simplification could be done in either step and is valid, unless we agree that specific non-visual information needs encoding inside mathlist or tex.

@Happypig375
Copy link
Collaborator

This is a bug in MathList->TeX code. If we use \mathbf instead of \mathrm, aka \mathbf{Gap}^2\mathbf{gb}, the 2 is not bolded and displays as so. However, when we convert the MathList back to TeX, it becomes \mathbf{Gap^2gb} and the 2 becomes bolded.

@Happypig375 Happypig375 added the Resolution/Fixed The described issue is fixed. label Mar 15, 2020
@Happypig375
Copy link
Collaborator

Fixed! Now the result is \mathrm{Gap^{\mathnormal{2}}} which is the true representation of \mathrm{Gap}^2 in CSharpMath.

[Fact] // This is for https://github.com/verybadcat/CSharpMath/issues/59
public void TestFontInsideScript() {
var list = LaTeXBuilder.MathListFromLaTeX(@"\mathbf{Gap}^2");
Assert.Collection(list,
CheckAtom<Variable>("G", G => Assert.Equal(FontStyle.Bold, G.FontStyle)),
CheckAtom<Variable>("a", a => Assert.Equal(FontStyle.Bold, a.FontStyle)),
CheckAtom<Variable>("p", p => {
Assert.Equal(FontStyle.Bold, p.FontStyle);
Assert.Collection(p.Superscript,
CheckAtom<Number>("2", two => Assert.Equal(FontStyle.Default, two.FontStyle))
);
})
);
Assert.Equal(@"\mathbf{Gap^{\mathnormal{2}}}", LaTeXBuilder.MathListToLaTeX(list));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution/Fixed The described issue is fixed. Type/Bug
Projects
None yet
Development

No branches or pull requests

3 participants