Convert source code to LaTeX

I often come across many physical equations implemented in Java and Fortran. In most cases, these equations are copied directly from an advanced physics textbook or publication. The equations in their original form are fairly easy to read because they are usually typed in LaTeX. However, when these equations are translated into code, they look like gibberish. Even using short domain names as suggested here , or expanding the equation into several lines does not make it look as intuitive as the version of the set.

Is there any tool that can parse the Java / Fortran source file and output it to LaTeX, converting all the math expressions to their LaTeX equivalent. For instance,

Math.sqrt(Math.pow(a,2) + Math.pow(b,2))

converted to

\sqrt{a^2 + b^2}

Just to be clear. I am not looking for solutions that allow LaTeX to be included as part of the comments / javadoc. Because it will only produce the LaTeX output of my comments, not the expression in the source code.

+5
source share
1 answer

I think I saw something like your request made using the jetbrains mps projection editor . He used to show arithmetic expressions in the source code as latex visualized equations. Although I don’t remember exactly where I saw it. Perhaps it was mbeddr .

, : ATL . Java . EMF Java. MoDisco Java 1.5. EMF. , Xtext.

+1

All Articles