GeneralConvert a/b to \frac{a}{b}

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
diegocueva
Posts: 1
Joined: Tue Dec 09, 2014 10:36 pm

Convert a/b to \frac{a}{b}

Post by diegocueva »

Hello:

Somebody knows a converter to translate normal math expression like 1+(1/pi) to LateX language 1+\frac {1} {$\pi$}

Thanks in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Convert a/b to \frac{a}{b}

Post by Johannes_B »

Hi and welcome,

to be honest, i don't know if there is a converter out there. But i know one thing for sure. Everything which is converted automatically to LaTeX needs careful checking and lots of fixing, as a converter cannot understand the equation.

Typing it directly will be more save and hence you will be faster.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10361
Joined: Mon Mar 10, 2008 9:44 pm

Convert a/b to \frac{a}{b}

Post by Stefan Kottwitz »

Hi Diego,

welcome to the forum!

There's pretty new TeX engine called ConTeXt. It provides a module with the name calcmath, which does what you want, directly within the code. It's implemented in Lua, so it should be possible to make it work with LuaLaTeX, because the ConTeXt syntax is very different.

Here is a compilable example:

Code: Select all

\usemodule[calcmath]
\startluacode
function moduledata.calcmath.tex(str,mode)
    context(moduledata.calcmath.totex(str,mode))
end
\stopluacode
\starttext
\displaycalcmath{1+(1/pi)}
\stoptext
This gives:
calcmath.png
calcmath.png (5.42 KiB) Viewed 3669 times
Already

Code: Select all

\usemodule[calcmath]
\starttext
\displaycalcmath{1+(1/pi)}
\stoptext
would suffice, but the additional code above fixes a problem with scaling of the delimiting parentheses.

Stefan
LaTeX.org admin
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Convert a/b to \frac{a}{b}

Post by Johannes_B »

Oh, that looks interesting. I wonder how powerful it is. Seems like i have something to do this evening. :-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10361
Joined: Mon Mar 10, 2008 9:44 pm

Re: Convert a/b to \frac{a}{b}

Post by Stefan Kottwitz »

Convert it to a package usable with LuaLaTeX. Or introduce it in a blog post on TeXwelt and here in English. ;)

Stefan
LaTeX.org admin
Post Reply