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

Using LaTeX in WordPress

Image Transparency Bug

Saturday 17th March 2007

Filed under: — Steve @ 4:14 pm

Some versions of ImageMagick fail to process the transparency command properly. If you find that this is causing problems for you then in class.latexrender.php remove the transparency command

-transparent "#FFFFFF"


// imagemagick convert ps to image and trim picture
$command = $this->_convert_path." -density ".$this->_formula_density." -trim -transparent "#FFFFFF" ".$this->_tmp_filename.".ps ".$this->_tmp_filename.".".$this->_image_format;


// imagemagick convert ps to image and trim picture
$command = $this->_convert_path." -density ".$this->_formula_density." -trim ".$this->_tmp_filename.".ps ".$this->_tmp_filename.".".$this->_image_format;

Thanks to Kevin Knuth for pointing out this workaround.


RSS feed for comments on this post.

  1. Hi,

    The link to download the plugin is returns a 404 error.

    Comment by Kenny — Saturday 17th March 2007 10:50 pm #

  2. Oh thanks for pointing that out. The download should be available now.

    Comment by Steve — Saturday 17th March 2007 11:06 pm #

  3. I having trouble intalling the plugin. I installed it locally(WAMP).
    I already have the image of the latex in the folder /latexrender/pictures, but i can’t see the image on the wordpress, it only show the alt of image. Anybody can help me please? Thank you

    Comment by Nirwan — Sunday 18th March 2007 3:14 am #

  4. The most likely cause is an error in the HTML path to the picture which is set in the line in latex.php
    $latexrender_path_http = "/latexrender";
    Have a look at the source code of the page and you may well be able to spot the error in <img src=”…

    Comment by Steve — Sunday 18th March 2007 12:39 pm #

  5. Hello,
    First of all, thanks very nice plugin,

    I have a little suggestion:
    instead of

    in class.latexrender.php

    This shows formulae in ordinary mode and not intext mode – so margings of sums in integrals go under and above the symbol instead of at the right of them.


    Comment by Artyom — Sunday 8th April 2007 6:41 am #

  6. Another way to achieve the same effect is to use \displaystyle either in class.latexrender.php or in the formula itself, for example \displaystyle \int_{0}^{1}\frac{x^{4}\left( 1-x\right) ^{4}}{1+x^{2}}dx=\frac{22}{7}-\pi instead of \int_{0}^{1}\frac{x^{4}\left( 1-x\right) ^{4}}{1+x^{2}}dx=\frac{22}{7}-\pi. Much of the time the formula is required in the midst of text where text mode is better but this way the writer can choose whichever method they wish.

    Obviously you are free to change the code on your system to whatever suits you best.

    Comment by Steve — Sunday 8th April 2007 10:43 am #

  7. I’d want to ask: which version of ImageMagick shows this kind of problem?

    Comment by Abel Cheung — Friday 13th April 2007 6:33 pm #

  8. I had a transparency problem with ImageMagick-6.3.1-Q16 (on Windows XP) which disappeared when I downgraded to ImageMagick 6.2.8-Q16 but someone else who used 6.3.1 didn’t have the same problem. I never got to the bottom of it. Kevin Knuth didn’t say which version he was using.

    Comment by Steve — Friday 13th April 2007 6:44 pm #

  9. A blind shot: can ‘-transparent “white”‘ cure the problem?
    I haven’t encountered such error before, so can’t say much about it.

    Comment by Abel Cheung — Friday 13th April 2007 9:57 pm #

  10. Sorry to drag up this issue again, but I believe the problem is related to the quotation marks present around #FFFFFF – i.e. the escaped double quotation marks (“). Replacing -transparent “#FFFFFF” with -transparent #FFFFFF solves the problem quickly and easily. I haven’t viewed the source code for IM, but I guess this is a bug with the command-line options processing suite.

    Comment by Carl Turner — Saturday 2nd June 2007 5:39 pm #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


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