Latex Code & Mathematical symbols
Posted October 17th 2011, 9:28pm
Pre-requisites: All-forum supported; Latex code Knowledge

The source code isn't made by me; but its a dream come true for any engineer/math teacher's forum & the likes. I happen to come across this http://www.forkosh.dreamhost.com/source_mathtex.html & eagerly wanted to integrate it in my forum.

1)In the sidebar widget I added
<script type="text/javascript" src="http://[url=http://www.watchmath.com/main/cgi-bin/mathtex3.js"></script>]www.watchmath.com/main/cgi-bin/mathtex3.js"></script>[/url]
<script type="text/javascript">window.mathPreamble =
 '\usepackage[usenames]{color}\color{brown} \gammacorrection{0.7}\dpi{140}\png \large ';replaceMath( document.body );</script>

or you can add this in title description of the forum (in case you don't have sidebar widgets or any other place such that this code is executed everywhere

2)You can play with these values to get appropriate display results
\color{brown} \gammacorrection{0.7}\png\dpi{140} \large


for instance
color values:blue,black,green,white...
size values:large,normal,small
img values:png,gif
dpi values:upto 300 (increases loadtime)
gammacorrection: upto 4.5 (hit&trial method)

Image

3]You are done. Post a message in this format

Use $latexcode$ to display inline or $$latexcode$$ to display as centered linebreak. All the messages on any page are parsed automatically to generate beautiful calculus/symbols & what not

fOR BEGINNERS:

You can get/generate latex codes from here:
http://www.sciweavers.org/free-online-latex-equation-editor

For an integral of trigonometry this code is generated
int_{0}^{pi} sin x , dx = 2

we write it as

$int_{0}^{pi} sin x , dx = 2$

...& the result

More complex latex codes generate this
Image
such examples can be found here: http://latexsearch.com/home.do

I think such has never been attempted before on forumotion forums, mostly the forums using latex renderers & host the whole rendering engine at their personal servers; which isn't possible for us!!
φ
Posts:
Avatar
Guest
Latex Code & Mathematical symbols
Posted October 18th 2011, 12:18am
This seem nice..

Are you math teacher or something?
φ
Posts: 22
Joined: October 14th 2011, 11:00pm
Latex Code & Mathematical symbols
Posted October 18th 2011, 12:29am
put it mildly...YES
φ
Posts:
Avatar
Guest
Latex Code & Mathematical symbols
Posted October 20th 2011, 2:06pm
[align=center]Update for a BUGG[/align]

replaceMath( document.body );

The part of the code was interfering when after inserting latex code in $---$ tag the user uses preview function or quotes another or edit his reply, because the code parses all the tags $---$, present in whole page.

User inputs code:

Image

Previews/edit afterwards

Image

This problem has been solved by the discussion here: http://www.webdeveloper.com/forum/showthread.php?t=232018

<script src="http://[url=http://www.watchmath.com/main/cgi-bin/mathtex3.js?"]www.watchmath.com/main/cgi-bin/mathtex3.js?"[/url] type="text/javascript"></script>
<script type="text/javascript">window.mathPreamble =
 '\usepackage[usenames]{color}\color{brown} \gammacorrection{0.7}\dpi{140}\png \large ';onload = function () {
var els = document.getElementsByTagName("div");
var i = els.length;
while (i--) {
if (els[i].className=="postbody") {
replaceMath(els[i]);
}
}
};</script>


Above code directs mathtex parse $--$ tags only in 'postbody' class & will not alter editor code because it follows different class

Dion/LGForum question.
Wy can't we use this code?
replaceMath(document.getElementByClass("postbody"));
φ
Posts:
Avatar
Guest
Latex Code & Mathematical symbols
Posted October 20th 2011, 4:05pm
That looks to be a better solution than messing around with the editor.

Why don't you try it and see what happens? You would need code of the form:

var x=document.getElementsByClassName('postbody');
for (i=0;i<x.length;i++) {replaceMath(x[i]);}
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357

Who is online

Users browsing this forum: No registered users and 0 guests