Convert an Equation Editor Object back to plain text

  • Thread starter Thread starter Muskyboi
  • Start date Start date
  • Tags Tags
    Convert Text
AI Thread Summary
The discussion revolves around finding a tool to convert LaTeX mathematical expressions into a simpler plain text format. Participants mention that while no specific tool was identified for this exact conversion, alternatives like Pandoc and various online converters were suggested. The conversation highlights the challenges posed by different source formats, such as images or PDFs, which complicate the conversion process. Suggestions for using OCR software were made, although results from tools like FreeOCR were unsatisfactory. Some users pointed out that Wolfram Alpha successfully converts LaTeX to a readable format, albeit with some limitations regarding character sets. Other resources, including Mathpix and i2OCR, were also mentioned as potential solutions for converting mathematical equations into plain text. Overall, the discussion emphasizes the complexity of the task and the need for effective tools in mathematical text conversion.
Muskyboi
Messages
10
Reaction score
0
Is there a tool that can convert something like this:
1595065591933.png


which when copied as plain text looks like this: \frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)

To this: 4/pi*sin(x)+4/(3pi)*sin(3x)+4/(5pi)*sin(5x)+4/(7pi)*sin(7x)+4/(9pi)*sin(9x)
 
Physics news on Phys.org
Muskyboi said:
Is there a tool that can convert something like this:
View attachment 266516

which when copied as plain text looks like this: \frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)

To this: 4/pi*sin(x)+4/(3pi)*sin(3x)+4/(5pi)*sin(5x)+4/(7pi)*sin(7x)+4/(9pi)*sin(9x)

1595103593915.png


What format is the source? Is it just a JPEG or BMP picture, or a PDF snapshot? Or something copy/pasted from MSWord? The source format will make a big difference in how difficult the conversion will be, IMO.
jedishrfu said:
it would be an interesting parsing project in a Comp Sci course on Compilers.
Absolutely. It would be a fun project, if the input format was something reasonable (instead of having to do full character recognition from a BMP file as a first step). :smile:
 
I thought the source was just the latex string to convert to a plain text target

A related fun project would be conversion to character graphics:

Code:
              //\\ pi/2
            //
           // sin(x) dx
          //
       \\// 0
come in useful source code

This would come in useful in source code comments or markdown where the viewer uses character graphics.
 
Oh, oops, I think you're right. I misread the OP to be "convert from this math equation to LaTeX". Sorry, nothing to see here, everybody move along... o0)
 
jedishrfu said:
I thought the source was just the latex string to convert to plain text
And yeah, that's a MUCH easier problem to assign in a compiler class. :wink:
 
What about exporting it as a PDF or PNG file and using OCR software? I tried with FreeOCR on the PNG in the OP, but it did not do very well. Maybe better OCR software would do a better job.

FreeOCR converted it to
%si.1.1[x)+% sin(3x)+% sin(5x)+% sin(Tx) + sin[9.\'

Not a good result. But I have seen OCR software do some impressive things.
PS. I just tried a couple of online TEX to TXT converters and they did not work well.
 
Last edited:
Input: \frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)https://www.wolframalpha.com/input/?i=+\frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)

1595221901334.png

produces

4/π sin(x) + 4/(3 π) sin(3 x) + 4/(5 π) sin(5 x) + 4/(7 π) sin(7 x) + 4/(9 π) sin(9 x)
also interesting:

https://mathpix.com/
http://www.i2ocr.com/free-online-math-equation-ocr
http://www.inftyproject.org/en/index.html
 
Last edited:
  • Like
Likes Muskyboi and FactChecker
robphy said:
Input: \frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)https://www.wolframalpha.com/input/?i=+\frac{4}{\pi}\sin\left(x\right)+\frac{4}{3\pi}\sin\left(3x\right)+\frac{4}{5\pi}\sin\left(5x\right)+\frac{4}{7\pi}\sin\left(7x\right)+\frac{4}{9\pi}\sin\left(9x\right)

View attachment 266604
produces

4/π sin(x) + 4/(3 π) sin(3 x) + 4/(5 π) sin(5 x) + 4/(7 π) sin(7 x) + 4/(9 π) sin(9 x)
also interesting:

https://mathpix.com/
http://www.i2ocr.com/free-online-math-equation-ocr
http://www.inftyproject.org/en/index.html
This is exactly what I was looking for. Thank you.
 
  • #10
robphy said:
produces

4/π sin(x) + 4/(3 π) sin(3 x) + 4/(5 π) sin(5 x) + 4/(7 π) sin(7 x) + 4/(9 π) sin(9 x)
For the record: When you hover the mouse over the picture of the equation, extra buttons appear and the one on the right brings up the plain text

1595505922395.png
 
  • #11
The only potential problem with Wolfram's plain text is that it uses the extended character set, so ##\pi## instead of Pi. That is acceptable in many places that you might paste it, but not everywhere.
 
  • #12
Turns out Excel (?:)) accepts ##\pi## as a name, but of course it wants all the asterisks :frown:

π 3.141592654 (formulas|create from selection)

=4/π* sin(x) + 4/(3 *π) *sin(3* x) + 4/(5 *π) *sin(5* x)+ 4/(7 *π)* sin(7 *x) + 4/(9* π) *sin(9* x)

does the work an comes up with a value
 
  • Like
Likes sysprog and FactChecker
Back
Top