Page 1 of 1

A half-solution to the problem of equations

Posted: 2009-03-04 03:19pm
by erik_t
It's come to my attention that LaTeX is (or at least can be) supported for phpBB, but phongn has pointed out to me that there's some concern about arbitrary code execution within phpBB.

I note the following. I can type an equation that is hard to read in plaintext, say:

Code: Select all

del(u)/del(t) + u * del(u)/del(x) = del^2(u)/del x^2
(the nonlinear scalar 1-D wave equation with viscosity) and expect many people to not know what the hell I'm doing. However, it's much easier to interpret nice happy LaTeX. They even have a helpful friendly image-embedding system, but it doesn't seem to work here. I think question marks in links break everything. Anyway, I have found a workaround.

If you select the "url" option from the dropdown box, and then embed it in a (code) box, then folks can copy and paste to see a nice friendly version of the equation.

Like so.

Code: Select all

http://latex.codecogs.com/gif.latex?\frac{\partial&space;u}{\partial&space;t}&space;+&space;u&space;\frac{\partial&space;u}{\partial&space;x}&space;=&space;\frac{\partial^2&space;u}{\partial&space;x^2}
This awesome latex magic can be generated by hitting up the Code Cogs LaTeX equation editor and selecting "url" from the dropdown menu, then embedding the link in a (code) box. Copy and paste. Simple as pie.

Only problem I currently see is this could break page-formatting, as the links can get terribly long and you can't use (size) commands within a (code) box. Can anyone think of a resolution to this?

Even as it is, it seems useful for SLAM and things. I bet most of the folks typing hairy-ass equations already know LaTeX anyway.

Re: A half-solution to the problem of equations

Posted: 2009-03-04 03:27pm
by erik_t
Aha! Tinyurl!

Image

A shame about the crappy transparency. Hmmm. Making it a link is the best thing I can think of. It might be less critical for those using a forum view other than THE ONE TRUE MILLENNIUM FALCON.

Re: A half-solution to the problem of equations

Posted: 2009-03-04 03:27pm
by Bounty
Can anyone think of a resolution to this?
Save the gif, host it on Photobucket, embed as image from there?

Re: A half-solution to the problem of equations

Posted: 2009-03-04 03:33pm
by erik_t
I am sympathetic to fears of tinyurl, so perhaps a better solution would be to link to the preview page:

http://preview.tinyurl.com/cahgxb

and have it be understood that latex.codecogs.com is effectively a whitelist.


Just throwing these things out there.

Re: A half-solution to the problem of equations

Posted: 2009-03-04 07:56pm
by erik_t
Well, we wouldn't be the first board to just mooch off of Code Cogs. I don't think that anything short of a full equation renderer is sufficient, honestly. I can't imagine unicode and html would grant anything more than special characters, which are nice but IMHO insufficient (although now that we have super/subscript maybe the problem is less severe anyway).

This is truly a zero-work solution, though, on the part of the board administration. I mean I'm going to be doing things with this method from now on. I just think we should consider making it an officially-encouraged method, so that people know about it if nothing else.

Re: A half-solution to the problem of equations

Posted: 2009-03-05 10:33am
by phongn
Destructionator XIII wrote:
erik_t wrote:I don't think that anything short of a full equation renderer is sufficient, honestly.
Do you have an example in mind?
Matrices, summations, combinations and permutations?

Re: A half-solution to the problem of equations

Posted: 2009-03-05 11:44am
by erik_t
There's an option to have the background be white instead of transparent.

And inlining tinyurl images leaves no more potential for abuse than inlining ANY images.

Image

Image

While the HTML/CSS/etc magic is impressive, this seems like an easy and permanent resolution to the problem.

Re: A half-solution to the problem of equations

Posted: 2009-03-05 11:46am
by phongn
Destructionator XIII wrote:edit: oh drat, those probably wouldn't look so good if the matrix was 3x3 rather than 2x2, for example, since I hardcoded 2x font size. Some CSS trickery might be able to fix this though; I'll have to play around with it when I have more time.
There's an ongoing project to use CSS2 to display MathML, which gives significantly more precise layout compared to HTML tables.

Re: A half-solution to the problem of equations

Posted: 2009-03-05 11:52am
by Darth Wong
Thanks for looking into this, erik. It's still inelegant in the sense that it's not self-contained or editable (and posts reliant upon hosted images would become meaningless if those hosted images are taken off-line), but it's certainly better than clumsily trying to kludge together something the way we've done it in the past.

Re: A half-solution to the problem of equations

Posted: 2009-03-06 04:24am
by Surlethe
Would it take too much server time and space to have a script on the server end that takes whatever's between [latex][/latex] tags, turns it into an image, and embeds it where the tags were?

Re: A half-solution to the problem of equations

Posted: 2009-03-06 06:46pm
by darkjedi521
I know I've come across some server side scripts that can be passed a string of latex code and generate an image on the fly. Down side is the latex gets compiled every page load though. If there's interest, I'll go see if I can find them again.