Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] LaTeX tags
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
  • 3
[Completed] [ZB] LaTeX tags; for equations
Tweet Topic Started: Sep 13 2009, 12:39 AM (875 Views)
Magrathean Sep 13 2009, 12:39 AM Post #1
Member Avatar


Posts:
24
Group:
Member
Member
#2,334
Joined:
Feb 14, 2009
If you look here, you'll see that Sirus has posted an equation (if you click on it, it should open a popup displaying the code it was generated with). It was coded in TeX (or LaTeX), a mathematics scripting language which is much more powerful than what the ZB bbcode tags let me do (i can type x2, for example, but try posting the square root of x without doing x1/2). PhysicsForums.com has a LaTeX code with which its users are able to post complex mathematical equations (for a guide, click here). I'd like something like this for my forum too, since it's a scientific forum (pleeeeeease!). Is it possible?

Thanks a ton in advance. :)
Posted Image
Free ZetaBoards astronomy forum -- join today!
Offline Profile Goto Top
 
... Sep 14 2009, 09:25 AM Post #2
...

Posts:
451
Group:
Dedicated
Member
#311
Joined:
Jul 26, 2008
*bump, because I could be interested in this as well*
Offline Profile Goto Top
 
Choco Sep 14 2009, 02:02 PM Post #3
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
Nemomon
Sep 14 2009, 09:25 AM
*bump, because I could be interested in this as well*
So you'd like it where if you type:
[tex]\sqrt{x}[/tex]
It'll render:
Posted Image?

I'll get right on it. :)
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
Magrathean Sep 14 2009, 02:19 PM Post #4
Member Avatar


Posts:
24
Group:
Member
Member
#2,334
Joined:
Feb 14, 2009
Exactly, and also other TeX/LaTeX code, please.

Thanks a bunch, Choco. ^_^
Posted Image
Free ZetaBoards astronomy forum -- join today!
Offline Profile Goto Top
 
Choco Sep 14 2009, 04:07 PM Post #5
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
Try something like this. Put it anywhere:
Code:
 

<script type="text/javascript">
//Latex bbcode, by Choco of ZBC
$(function(){
$("td.c_post:contains([tex])").each(function() {
x = $(this).html();
x = x.replace(/\[tex\](.+?)\[\/tex\]/gi,function(a,b) {
return "<img src='http://latex.sidoh.org/?render="+escape(b)+"' />";
});
$(this).html(x);
});
});
</script>

Then just do this wherever you'd like latex:
[tex]any expression here[/tex]
And it should work like a charm.
Just please do note that adding single quotes (e.g. ') will break the image tag, which is a bad thing. So don't use single quotes in your latex expressions. If this is a problem, just post back and I'll mod it to work with single quotes as well.
Enjoy! :)

By the way, can I have a link to your forum? I'd be interested in seeing what it's about :)
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
... Sep 14 2009, 04:27 PM Post #6
...

Posts:
451
Group:
Dedicated
Member
#311
Joined:
Jul 26, 2008
Thanks, works for me well :). I don't think it is using single quotes much, so fixing the code isn't an urgent thing, however, if You once will be bored.... :r

As for my board, it is about RockMan, however few times I needed to post some math things, and I was forced to look at wiki for images :(.

EDIT: BTW, version with TEX button on posting page and which would work on preview too... (if that isn't a big request... :r)
Edited by ..., Sep 14 2009, 04:42 PM.
Offline Profile Goto Top
 
Magrathean Sep 14 2009, 06:14 PM Post #7
Member Avatar


Posts:
24
Group:
Member
Member
#2,334
Joined:
Feb 14, 2009
Yes! It's beautiful! Thank you, Choco. ^_^ Is there a way to invert the colors of the equation so it'd look great on my board, which has a dark background? If not, i understand what you've done has already been great help. I should begin gathering a LaTeX cheat sheet for my members now...

My board, Anatomia Universalis (latin for "Anatomy of the Universe"), is a board for astronomy news, articles, discussion, learning, etc. It's an ambitious project and so far i haven't had a lot of luck getting staff members who are hardworking and have a lot of free time, which is why you'll find it almost empty, but please don't let that influence you. The Mars section has a few completed articles/topics/threads (the ones which don't have a red circle to the left), especially the part about the missions sent to the red planet (you won't be able to see any of the images as a guest). Thanks for the interest. ^_^
Edited by Magrathean, Sep 14 2009, 06:33 PM.
Posted Image
Free ZetaBoards astronomy forum -- join today!
Offline Profile Goto Top
 
... Sep 15 2009, 06:16 AM Post #8
...

Posts:
451
Group:
Dedicated
Member
#311
Joined:
Jul 26, 2008
I'm not sure, if that is a bug or not, but that code works well however it doesn't support plus + sign.

[tex]ax^2+bx+c=0 \Rightarrow X_{1,2}=\frac{-b\mp\sqrt{\delta}}{2a}[/tex]

And I would like be interested as well if it could be more visible on darker themes.
Edited by ..., Sep 15 2009, 06:58 AM.
Offline Profile Goto Top
 
... Sep 15 2009, 10:30 AM Post #9
...

Posts:
451
Group:
Dedicated
Member
#311
Joined:
Jul 26, 2008
So I tried this:

[tex]ax^2+bx+c=0 \Rightarrow X_{1,2}=\frac{-b\mp\sqrt{\Delta}}{2a}[/tex]

and in output I got this:

Posted Image

Hwever, when I went to Latex page, and I input exactly same value in their box, I'm getting this:

http://latex.sidoh.org/?render=ax^2%2Bbx%2Bc%3D0%20\Rightarrow%20X_{1%2C2}%3D\frac{-b\mp\sqrt{\Delta}}{2a}

Posted Image

So, looks like that code above don't like %2B, %3D &c.
Offline Profile Goto Top
 
Firestrife2 Sep 16 2009, 06:13 PM Post #10
Member Avatar


Posts:
159
Group:
Dedicated
Member
#2,094
Joined:
Jan 21, 2009
That is because a "+" in a URL is equal to a whitespace(or " ").

Obviously that wouldn't work well when the return is: " return "<img src='http://latex.sidoh.org/?render="+escape(b)+"' />";"

:/
Posted Image

Posted Image
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Completed Requests · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2
  • 3

Track Topic · E-mail Topic Time: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy