Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2008-04-23 22:49:32
- alex9142
- Member
- Registered: 2008-03-17
- Posts: 45
Re: [request] Equation Editor
I added the page that you’ve sent in my bookmarks. It’s great! But unhappilly it doens’t show the upsidedown A
But I found out this page: http://web.mit.edu/rsi/www/2003/help/faq/latex/#faq19
Offline
#14 2009-12-11 15:06:34
- progo
- Member
- Registered: 2009-12-11
- Posts: 11
Re: [request] Equation Editor
Sorry to bump an old thread, but I find it very alarming that TextPattern currently has no decent LaTeX plugins to work out. The German blog entry has vanished, so does anyone know a good LaTeX hack? I say hack, because — at the moment — I understood that
- There’s no easy way to write out plugins to adjust or enhance Textile, or add new Textile markup
- The LaTeX converters in general are very hacky. I used a plugin in a WordPress project that would use an external LaTeX to PNG converter, and I’d seek something like that in TXP as well because not all the hosts are willing to provide tools for own LaTeX, Ghostscript and PNG generation.
Naturally, I’d love to have Textile tags such as $math$ to work as in a LaTeX document. Using XML tags would surely be easy to code but aesthetically it is not the best solution and can be less portable as well!
Offline
Re: [request] Equation Editor
Checkout an earlier blog post I made on Math on the Web
Basically there are several services that have a REST interface allowing you to include an image in your blog which is latex rendered by the remote service and sent back as an image.
Thus this:
!http://www.codecogs.com/eq.latex?\int_{-\infty}^{\infty}e^{-x^{2}}dx=\sqrt{\pi}!Produces this:
Offline
#16 2009-12-11 18:40:43
- progo
- Member
- Registered: 2009-12-11
- Posts: 11
Re: [request] Equation Editor
Oh yes, thank you for suggestion. :)
The issue could be that the image tag is very messy and very, very unsemantic. I like to do posts the LaTeX way, so every mathematical x and y in the correct context should be put through that image tag. (Don’t worry, the LaTeX plugins in WP handle the alt texts fine.)
Perhaps I’ll go on and write a tag function first, and then figure out how to integrate it into the Textile interpreter, if possible.
Offline
#17 2010-04-30 17:20:14
- progo
- Member
- Registered: 2009-12-11
- Posts: 11
Re: [request] Equation Editor
So I finally needed to write some nice math in my blog, so I wrote the necessary code. All it lacks is caching. With this, you can write easy and TeX-y inline math using $$‘s as a block mark. As you can see from the first snippet, it’s easy to modify to whatever you want.
Put this in classTextile.php, in the function body of graf. Right after line 679 was a good spot for this:
$text = $this->doSpecial($text, '$$', '$$', 'fLatex');
The function, fLatex can be put after graf:
/* Parse LaTeX $$ $$ strings into pictures */
function fLatex($m)
{
@list (, $before, $text, $after) = $m;
$uri = "http://l.wordpress.com/latex.php";
$background = "000000"; // colours for pictures
$foreground = "FFFFFF";
$size = "1";
$style = "tex";
return " <img class=\"$style\" src=\"". $uri . '?latex='
. rawurlencode($text) . "&s=$size&fg=$foreground&bg=$background\""
. " alt=\"$text\""
. " />";
}
It’s no rocket science to adjust the settings to one’s preference. I chose wordpress’s one because it allows me to define fore and background colors. Important when you run blog white-on-black.
Last edited by progo (2010-04-30 17:21:54)
Offline
#18 2010-05-22 07:41:30
- jeadorf
- Plugin Author
- From: München, DE
- Registered: 2010-04-13
- Posts: 12
Re: [request] Equation Editor
You might want to look at the (quite recent) plugin jea_latex_txp
Offline
#19 2010-05-22 07:56:52
- progo
- Member
- Registered: 2009-12-11
- Posts: 11
Re: [request] Equation Editor
^ It looks very good, but doesn’t cooperate with safe mode / restricted PHP sessions. And though it is nice for whole blocks of math, inlining long XML tags looks ugly and messy. I would have used it if my host weren’t for safety.
Offline
#20 2010-05-22 09:43:47
- jeadorf
- Plugin Author
- From: München, DE
- Registered: 2010-04-13
- Posts: 12
Re: [request] Equation Editor
Alright. In such a case I would probably stick to solutions like mimetex or if you do not care about the external dependency there are (you probably know them) remote services like codecogs.
Concerning the jea_latex_txp plugin I might add an alternative tag attribute for shorter math formulae like <txp:jea_latex code=’$\square$’ /> in a future version. The difficulties are not on the textpattern plugin side, though. Letting the plugin use codecogs as a renderer is a matter of changing one single line, and I might want to make that configurable, as a fallback for those who are not able to put or run stuff on their server. Do you know whether and how I could change latex2image to make it compliant to your PHP environment (or similar ones)? Not using the shell or external programs does not seem to be a choice.
Offline
#21 2010-05-22 11:24:30
- progo
- Member
- Registered: 2009-12-11
- Posts: 11
Re: [request] Equation Editor
Yes, I have discarded many caching solutions because they can’t use file_get_contents
on local addresses.
In case you didn’t notice, I wrote a quick hack above that works for me, but only for inline math. By the way, using imagemagick to do the conversion works very well when the alternative options include quite much hassling with the ghostscript etc.
I couldn’t think of a good work-around when I blogged with WordPress and things haven’t changed since. The external picture provider is a solution. Perhaps the only one, perhaps not. It’s decent okay.
Offline
#22 2010-05-22 21:30:00
- jeadorf
- Plugin Author
- From: München, DE
- Registered: 2010-04-13
- Posts: 12
Re: [request] Equation Editor
Sure, I have already tested your nifty solution. It works like a breeze and it smoothly integrates into textile. It is good to know that there are a bunch of different solutions available, so we can always choose the one that satisfies the requirements in particular situations.
Offline