-
Notifications
You must be signed in to change notification settings - Fork 15
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
ODT output for fractions and non-italicized words in math #55
Comments
Ah, this LibreOffice math rendering is really frustrating. On the one hand, there are some issues with your TeX code - I would use
And it looks fine in Firefox: I also found, that LO really wants With these changes, it looks like this: I hope that I will be able to fix the space after "U", but I don't understand at all, why it joins "+ 4" to the fraction. It is just non-sensical, and I don't really know how to fix that. |
Yes, I see that I should use \mbox instead of \hbox; thank you very much for pointing that out! I could not get \mathrm to be reflected in the ODT file, but I do not need \mathrm since \mbox works. For the fraction: the ODT file is showing The original fraction problem persists in Word if I use LibreOffice to create the DOCX file, but if I open the ODT file directly in Word, Word gives the correct output. It is not often that one gets correct output from incorrect input! Or I guess the ODT file is correct and LO is interpreting it incorrectly? |
I would recommend to not use the plain TeX constructs in LaTeX math, they are quite hard to handle correctly by TeX4ht :/ We produce only MathML code, not StarMath that LibreOffice Math Guide describes, so it is not possible to change "frac" to "over", I am afraid. In the past, I thought that I could write code to transform MathML to this LibreOffice format, but then I found that it would be quite difficult, and that it isn't supported in Word anyway. So I abandoned that idea. I've found a mail about OpenOffice math support here: https://www.mail-archive.com/[email protected]/msg00200.html So my conclusion is that the fraction code produced by TeX4ht is correct, LO interprets it incorrectly, and Word interprets it correctly. The bad thing is that Word fails in other cases where LO works. |
Regarding the LaTeX -> HTML -> Word way, I think you would find other issues, like footnotes, and probably others. You should try it though. Don't forget to try the "mathml" option, as it is the only possible way how math could keep some formatting information. The downside is that ODT uses MathML as well, so it is quite likely that the issues from ODT will remain. You can also try pictures for math, which will keep the appearance, but you will lose the ability to edit formulas. For wrong fractions rendering, it seems that there is one attribute that can require to display fractions as
|
Random bystander
As far as I've gathered, that's not quite accurate. The internal format is actually a linear (asciimath-like) syntax (much like Word has a separate XML which also comes with an equivalent linearization called "unicode math"). When given an ODT with MathML in it, Libre Office appears to first convert it to its linear format and then back to MathML, replacing the original MathML. This process has a lot of bugs, unfortunately. (You can test this by opening an ODT, saving it again, and looking inside the file.) |
Hi Peter, thanks for your reply. I meant that if LO or Word have issues with MathML import, these issues should be similar regardless of whether that MathML comes from HTML, or from ODT. I guess that LO will translate it to its internal format in both cases. And yes, it is quite buggy. It renders the following MathML:
|
Yes, I've fixed that in TeX4ht sources. |
Although Word 2016 has the problem with fractions which I wrote about above, I just checked Word 2019, and it handles the fraction correctly. In other words, when Word 2019 opens the ODT file (with the make4ht build file attached to my original post), it renders the fraction correctly even once the editing window has been opened and closed. LibreOffice renders it incorrectly, and LO also exports a DOCX file which is incorrect when opened in Word. So for fractions, having Word 2019 (not 2016) open the ODT file is the best way to go. Unfortunately, Word, even Word 2019, cannot directly open the ODT file which make4ht generates from
When one tries to open the file despite the error, the math is not rendered. LibreOffice has no problem with this ODT file. I ran into other commands (my personal LaTeX macros, including an equation numbering command I mentioned in Issue #56) which, when run through make4ht, generated ODT files which neither Word 2016 nor Word 2019 can open, but which LibreOffice can open without problems. Therefore, for my use case, it seems best to use LibreOffice to open the ODT file and export a DOCX file, then fix the fractions using Word 2019. I also tried LaTeX -> HTML -> DOCX. Using Thank you for fixing in the TeX4ht sources the extra spaces being inserted after in-line math. |
It is good that they managed to fix the equations issue in the newer version. Regarding the failing files, could you try to make a MWE? It is possible that TeX4ht generates wrong ODT (but it would fail in LO too, I guess). I've tried your I didn't expect that Word would fail so badly with the HTML import, as it already should have some MathML support. I also don't understand why it shouldn't support images. I thought that it should support most features, except for footnotes and other stuff that has no native support in HTML. |
Yes, I can confirm that although Office 2016 and Office 2019 cannot open an ODT file produced from a LaTeX file with In the following file, there are exactly two lines between
As for the LaTeX -> HTML -> DOCX route, in case I was unclear, using |
There are certainly issues with your custom macros that cause wrong MathML structure. I would modify it in this way:
I changed |
The file "problem.tex"
has the LaTeX result
but make4ht's ODT translation appears in LibreOffice as
The problems are: an extra space between the U and the comma, and also before the final period; misplaced subscript of N_1^*; "such that" and "is" should not be italicized; "and" misinterpreted as a logical operator; "+4" incorrectly put in the denominator; and the chemical symbols in italics when they should not be italicized. I create the ODT file by running
make4ht -c config.cfg -e build.lua -f odt problem.tex
with the build.lua and config.cfg files attached (with .txt extensions) (see Issue #54). I tried replacing\hbox
with\textrm
but it did not help; nevertheless, I am open to replacing commands from Plain TeX in my input file with their LaTeX versions if it would help.build.lua,txt
config.cfg,txt
The text was updated successfully, but these errors were encountered: