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

TeX conversion failure without any indication of _what_ actually caused the failure. #6715

Closed
Pomax opened this issue Oct 3, 2020 · 4 comments

Comments

@Pomax
Copy link

Pomax commented Oct 3, 2020

I tried running pandoc 2.5 on Ubuntu 20 against the following maths tex:

\documentclass{article}

\begin{document}
\[
\int_{0}^{z}\sqrt{ \left (dx/dt \right )^2+\left (dy/dt \right )^2} dt
\simeq
\frac{z}{2} \cdot \left [ f\left( \frac{z}{2} \cdot \frac{-1}{\sqrt{3}} + \frac{z}{2} \right)
              + f\left( \frac{z}{2} \cdot \frac{1}{\sqrt{3}} + \frac{z}{2} \right)
          \right ]
\]
\end{document}

And get the following output:

[WARNING] Could not convert TeX math '\int_{0}^{z}\sqrt{ \left (dx/dt \right )^2+\left (dy/dt \right )^2} dt
  \simeq
  \frac{z}{2} \cdot \left [ f\left( \frac{z}{2} \cdot \frac{-1}{\sqrt{3}} + \frac{z}{2} \right)
                + f\left( \frac{z}{2} \cdot \frac{1}{\sqrt{3}} + \frac{z}{2} \right)
            \right ]', rendering as TeX
<p><br /><span class="math display">$$\int_{0}^{z}\sqrt{ \left (dx/dt \right )^2+\left (dy/dt \right )^2} dt
\simeq
\frac{z}{2} \cdot \left [ f\left( \frac{z}{2} \cdot \frac{-1}{\sqrt{3}} + \frac{z}{2} \right)
              + f\left( \frac{z}{2} \cdot \frac{1}{\sqrt{3}} + \frac{z}{2} \right)
          \right ]$$</span><br /></p>

However, this output does not identify which instruction is causing the conversion to fail. How do I force pandoc to tell me where things actually went wrong?

Note that dropping running latex test.tex or even dropping the equation into https://www.codecogs.com/latex/eqneditor.php works, so there's nothing that immediately jumps out as "this is probably what's wrong", so pandoc's help in actually identifying the problem would be greatly appreciated.

Also, on a secondary note, $$ as both start and end marker for maths mode is the legacy pure TeX syntax for maths mode, and isn't actually supported by LaTeX (and never has). Instead, the syntax is \[ at the start and \] at the end, so rewriting \[ ... \] to $$ ... $$ is pretty odd, and worth keeping \[ ... \].

(also see http://ctan.mirror.rafal.ca/info/l2tabu/english/l2tabuen.pdf, section 1.6 for this)

@jgm
Copy link
Owner

jgm commented Oct 3, 2020

You don't say what you're trying to convert this to. What is your output format and what command line, exactly, are you using? It looks as if you're targeting HTML, but using the default math processing option of "trying to fake it with unicode." This fails if you have things like fractions. If you have any kind of complex math, you need to use --mathjax or --katex or --webtex or --mathml one of the other supported math options. See the manual.

@Pomax
Copy link
Author

Pomax commented Oct 3, 2020

Ah, apologies, this was a straight up pandoc -s test.tex -o test.text as per the pandoc examples page (specifically, example 4). I'm not targetting HTML in the slightest, I'm trying to find any tool at al that will let me convert LaTeX to an ASCII form that people can reasonably read.

(specifically, for plain text comments in the source for https://pomax.github.io/bezierinfo as well as "what to show in case someone is weird enough to use Lynx")

I tried CADDVI, Tex2mail, Tex4ht, and ASCIITeX, and they're all pretty much terrible. Someone recommended giving pandoc a try, so I did. I google for the error it generates but every page I find with questions for this error also show that pandoc's pointing out where the error is (using the classic ^ to point to the offending symbol/sequence start), and was surprised that apparently, I don't get that same level of informative error.

@jgm
Copy link
Owner

jgm commented Oct 3, 2020

Pandoc will do a decent job of converting math to plain text, as long as the math doesn't contain things that are really hard to represent in plain text (mostly things that require vertical as well as horizontal arrangement, like fractions or matrices).

If you have complex equations, targeting plain text is probably an impossible goal.

@Pomax
Copy link
Author

Pomax commented Oct 4, 2020

Story of my life. I've written plenty of things to make the impossible possible, although at this point I really don't want to have to do this myself anymore... Thanks for the back-and-forth, I'll probably just cop out and embed the original LaTeX as comments/content instead =P

@Pomax Pomax closed this as completed Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants