This site is a showcase for using LatexRender for mathematics in WordPress

Using LaTeX in WordPress

Improved Output

Saturday 22nd January 2005

Filed under: — Steve @ 11:09 pm

Benjamin Schwartz has adapted class.latexrender.php to improve the quality of the output. He has used “the PNG format’s support for true alpha blending to make those jagged edges (on non-white background) disappear”. The text colour for both PNG and GIF are customizable as is the background colour for GIFs. The original settings are still available.

You can download the file here and view its effect at Digital Diary of Ben Schwartz. The enhancement works best on dark backgrounds so, if you are using Firefox or Opera then try switching the stylesheet to ‘Dark Fire’ on that page.

Some things to be aware of:

  • the improved output may have a small speed penalty
  • the system will only work with recent versions of ImageMagick (such as 6.1.2)
  • Internet Explorer on Windows does not show PNGs as transparent

Path Problems in Linux

Friday 14th January 2005

Filed under: — Steve @ 3:32 pm

If you can’t get LatexRender to work then comment out the 6 unlink lines in class.latexrender.php with // so that they look like this:
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".tex");
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".aux");
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".log");
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".dvi");
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".ps");
// unlink($this->_tmp_dir."/".$this->_tmp_filename.".".$this->_image_format);

Then look in the /tmp folder you have created and see what files have been created. If there’s a .ps file but no .gif or .png file then it may be because ImageMagick can’t find Ghostscript as detailed in Latexrender for WordPress under Mac OS X.

This is because in Linux, Imagemagick expects to find the gs file (Ghostscript’s binary) in /usr/bin. In fact, it may be in /usr/local/bin or somewhere else. You can either
1. reinstall Ghostscript into /usr/bin
or
2. change the path in Imagemagick’s file to tell it where to look. The file you want is delegates.mgk and might be found in /usr/share/ImageMagick, though this can vary. In this text file just alter /usr/bin/gs to the correct path – there may be 8 of these to change.
or
3. This is probably the simplest method. Make a symbolic link from /usr/bin/gs to /usr/local/bin/gs or wherever gs resides. How do I create a symbolic link?
or
4. See Marcin Gomulka’s comment below. This is great if you don’t have access to the server

Please let me know if this works for your installation.

IllustRender

Sunday 2nd January 2005

Filed under: — Steve @ 4:06 pm

Alex Gittens has released IllustRender to aid in drawing illustrations in WordPress
IllustRender is a plugin for WordPress, heavily based on LatexRender, which replaces illustration code in your posts with the actual illustration.

The LATEX Graphics Companion is the reference book to consult for such graphics. A couple of examples, rendered by IllustRender, are:

[illust]draw (0, 50)..(0,0)..(60,40)..(60,10)..cycle;[/illust] [illust]picture p; path q;
p := thelabel(btex \Large
\begin{minipage}{4in}
\begin{gather}
\iint\limits_A f(x,y)\,dx\,dy\qquad
\iiint\limits_A f(x,y,z)\,dx\,dy\,dz\
\iiiint\limits_A f(w,x,y,z)\,dw\,dx\,dy\,dz
\qquad\idotsint\limits_A f(x_1,\dots,x_k)
\end{gather}
\end{minipage}
etex,(0,0));
q := fullcircle scaled 2.5in;
fill q withcolor black;
clip p to q;
draw p rotated (90) withcolor white;[/illust]

 

This site is a showcase for using LatexRender for mathematics in WordPress