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

Could not convert TeX math \frac #7771

Closed
nopria opened this issue Dec 22, 2021 · 8 comments
Closed

Could not convert TeX math \frac #7771

nopria opened this issue Dec 22, 2021 · 8 comments
Labels

Comments

@nopria
Copy link

nopria commented Dec 22, 2021

I try to convert from markdown to rtf using

pandoc test.md -s --self-contained --webtex -o test.rtf

a very simple markdown file containing just

Equation $\frac{1}{2}$

and I get the warning message

[WARNING] Could not convert TeX math \frac{1}{2}, rendering as TeX

and of course in the RTF file the equation is not rendered.

Pandoc version

pandoc 2.16.2 Compiled with pandoc-types 1.22.1, texmath 0.12.3.2, skylighting 0.12.1, citeproc 0.6, ipynb 0.1.0.2

Under Ubuntu running inside Windows Subsystem for Linux.

@nopria nopria added the bug label Dec 22, 2021
@jgm
Copy link
Owner

jgm commented Dec 22, 2021

This isn't a bug, just a warning. Pandoc will try to convert TeX math to an equation that works in the target format, e.g. OMML equation in docx. If it can't do this, it issues this warning and includes the plain TeX code. RTF doesn't have a native equation syntax, and fractions can't be "faked" with plain text since they involve putting things in a vertical stack, hence this warning.

You might look at the --webtex option which would allow you to include images for the equations.

@jgm jgm closed this as completed Dec 22, 2021
@nopria
Copy link
Author

nopria commented Dec 22, 2021

The warning remains also if you try to obtain an RTF with equations rendered as images (which is what I'm trying to achieve), using the option --webtex=https://latex.codecogs.com/png.latex?.

@jgm
Copy link
Owner

jgm commented Dec 22, 2021

I'm sorry, I forgot that --webtex only works with HTML output.

@jgm
Copy link
Owner

jgm commented Dec 22, 2021

There's actually no reason we couldn't make --webtex work with RTF, and indeed with every format. I'll open a separate issue about this.

@nopria
Copy link
Author

nopria commented Dec 22, 2021

Ok, thanks.

I also tried conversion to RTF from HTML containing equation rendered as PNG, but I get the message

[WARNING] Could not fetch resource data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAXBAMAAAA1qkh7AAAAMFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEFS7zSLdRInvZpl2qzIdro3DAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAATElEQVQIHWNgVGZgYGBSARIMIbiIMKAEe+dSkDQM/P///wOMDaSZVmxgYIhhuMHA8IRhMUi8A4gZE4EE7wMgcY4VaEABDwND/P8fDADhqhD/i+mPyQAAAABJRU5ErkJggg==: image is not a jpeg or png

I checked the HTML and the image of the equation is a PNG.

Vector rendering

The PNG rendering obtained with the --webtex option is very bad quality, I don't know if here is a way to improve it. Another option would be to render equation as SVG using as final format ODT, which can contain vector graphics (whereas RTF can't, as I just discovered doing some tests).

@jgm
Copy link
Owner

jgm commented Dec 22, 2021

If you use ODT, you don't need to mess with images; ODT supports mathml and pandoc will do the conversion for you.

@nopria
Copy link
Author

nopria commented Dec 22, 2021

Even if ODT supports math rendering, the quality of math rendered by LaTeX is much higher, so I would prefer anyway to have LaTeX rendered images in ODT.

jgm added a commit that referenced this issue Dec 22, 2021
@jgm
Copy link
Owner

jgm commented Dec 22, 2021

I just pushed a fix to the problem with data URIs you noted above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants