Android Tutorial Displaying Math Formulas in pretty form

Hi,
I want to share with you one method to display math equations and formulas with a very good result without internet connection.I'm using it in one of my apps(in developing) and works fine with all the devices of probe(Galaxys(Mini2,S4),Nexus(7,5),Xperias,Tablets)(Since Android 2.3).

Step 1.-Add the File latexit.js to the Files Folder of the proyect

Step 2.-Create a WebView where you want to display the formula

Step 3.-Loads the webView with the next HTML code:
HTML:
"<html><head><script Type='text/javascript' src='file:///android_asset/latexit.js'></script></head><body><span lang="latex">\int3x</span></body></html>"

That's all, the script do all the work for us... where \int3x is the formula in latex and tags <span lang="latex"></span> put the formula in a pretty form

Notes:
1.-This java script of latex has a good support to make paragraphs, so it's a good idea(by experience) to show all the information in the same web view

2.-I haven't probe all the functions of the script, play with it to discover all

3.-To finish..Latex has a very good docs so it's very easy to learn it.(1 day or 2)

I attach a little example,it contains the script ,have fun...
 

Attachments

  • SC20140211-014859.png
    SC20140211-014859.png
    30.3 KB · Views: 1,592
  • PrettyMathFormulas.zip
    327.5 KB · Views: 1,638
Last edited:

JohnD

Active Member
Licensed User
Longtime User
Hi,
I want to share with you one method to display math equations and formulas with a very good result without internet connection.I'm using it in one of my apps(in developing) and works fine with all the devices of probe(Galaxys(Mini2,S4),Nexus(7,5),Xperias,Tablets)(Since Android 2.3).

Step 1.-Add the File latexit.js to the Files Folder of the proyect

Step 2.-Create a WebView where you want to display the formula

Step 3.-Loads the webView with the next HTML code:
HTML:
"<html><head><script Type='text/javascript' src='file:///android_asset/latexit.js'></script></head><body><span lang="latex">\int3x</span></body></html>"

That's all, the script do all the work for us... where \int3x is the formula in latex and tags <span lang="latex"></span> put the formula in a pretty form

Notes:
1.-This java script of latex has a good support to make paragraphs, so it's a good idea(by experience) to show all the information in the same web view

2.-I haven't probe all the functions of the script, play with it to discover all

3.-To finish..Latex has a very good docs so it's very easy to learn it.(1 day or 2)

I attach a little example,it contains the script ,have fun...

Thanks for the reply Citizen. Unfortunately, I am able to download PrettyFormulas.zip but not unzip it - "incompatible or corrupted file format". I'm using Windows..WinZip 17.5(10562). Also, where would I find latexit.js? I have found references to it on the web but not the actual file. Your help is appreciaeted. JD.
 

hdmiacc

Member
Licensed User
Longtime User
use kuizip.. maybe usefull for u.. free application

Thanks for the reply Citizen. Unfortunately, I am able to download PrettyFormulas.zip but not unzip it - "incompatible or corrupted file format". I'm using Windows..WinZip 17.5(10562). Also, where would I find latexit.js? I have found references to it on the web but not the actual file. Your help is appreciaeted. JD.
 

CitizenGokuMauricio

Member
Licensed User
Longtime User
Thanks for the reply Citizen. Unfortunately, I am able to download PrettyFormulas.zip but not unzip it - "incompatible or corrupted file format". I'm using Windows..WinZip 17.5(10562). Also, where would I find latexit.js? I have found references to it on the web but not the actual file. Your help is appreciaeted. JD.

I reload the .zip. I hope that solve the problem.
 

JohnD

Active Member
Licensed User
Longtime User
I reload the .zip. I hope that solve the problem.
The tutorial you set up was great regarding integration with latex! However, this solution does depend on an internet connection to format the formulas. I proved this by changing the uri reference in latexit.js on lines 55 and 57 of this file. I set it to a non-existant page "codecogs1":
B4X:
 txt = " <img src=\"http://latex.codecogs1.com/"+this.mode+".latex?"+ txt +"\" alt=\""+ txt +"\" title=\""+ txt +"\" border=\"0\" class=\"latex\" /> ";
            }
            else
            txt = " <img src=\"http://latex.codecogs1.com/"+this.mode+".latex?"+ txt +"\" alt=\""+txt+"\" border=\"0\" class=\"latex\" /> ";
The result was unformatted text. See attached file codecogs_latex.
 

Attachments

  • codecogs_latex.png
    codecogs_latex.png
    40.1 KB · Views: 709
Top