Convert an Equation Editor Object back to plain text

  • Thread starter Thread starter Muskyboi
  • Start date Start date
  • Tags Tags
    Convert Text
Click For Summary

Discussion Overview

The discussion revolves around the conversion of mathematical expressions from LaTeX format to plain text. Participants explore various tools and methods for achieving this conversion, including software options and programming projects.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants inquire about tools that can convert LaTeX strings to plain text, specifically looking for a transformation that simplifies the notation.
  • One participant mentions that pandoc can handle various conversions to and from LaTeX, suggesting it as a potential solution.
  • Another participant raises the importance of the source format, questioning whether it is an image or text, as this affects the complexity of the conversion process.
  • Some participants discuss the feasibility of using OCR software to convert images of equations into text, sharing mixed experiences with different OCR tools.
  • Several participants share links to online tools and resources that may assist in the conversion process, including Mathpix and i2ocr.
  • There is a mention of potential issues with character encoding in the output, particularly with the representation of π.
  • One participant suggests that converting LaTeX to character graphics could also be an interesting project.
  • Another participant notes that Excel can interpret π in formulas, but requires specific formatting.
  • Some participants express uncertainty about the effectiveness of various tools and methods, indicating that results may vary.

Areas of Agreement / Disagreement

Participants generally agree that there are multiple approaches to converting LaTeX to plain text, but there is no consensus on a single best method or tool. Several competing views on the effectiveness of different tools and techniques remain unresolved.

Contextual Notes

Participants note limitations related to the source format and the potential challenges of using OCR software, as well as issues with character encoding in the output.

Who May Find This Useful

This discussion may be useful for individuals interested in mathematical typesetting, software development related to parsing mathematical expressions, or those seeking tools for converting LaTeX to plain text.

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
I’ve not heard of such a tool. However, pandoc can do a variety of conversions to and from latex.

https://tex.stackexchange.com/questions/252203/tex-to-plain-text-or-doc

and here’s a list of other possible tools and plugins that do conversions

https://www.tug.org/utilities/texconv/textopc.html

it would be an interesting parsing project in a Comp Sci course on Compilers.
 
  • Informative
Likes   Reactions: berkeman
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   Reactions: 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   Reactions: sysprog and FactChecker

Similar threads

  • · Replies 11 ·
Replies
11
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 11 ·
Replies
11
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K