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

Using LaTeX in WordPress


Monday 12th December 2011

Filed under: — Steve @ 2:12 pm


is a tool to make it easy to embed LaTeX code in your webpages, even if the server-side software — like your wiki or blog program — doesn’t support it.

That means that you can type LaTeX in a rich text editor and have it rendered as an image. Such editors are not only found in blogs but also in webmail such as Gmail. This makes it easy to email complicated mathematics even if the recipient doesn’t use or understand LaTeX. It can also be used to preview mathematical posts, such as in Moodle forums, before posting.

mathcache is written by Randall Farmer. It works by using JavaScript to replace the code by an image rendered using mathTeX hosted on mathcache’s server. Bookmarklets are provided which work well in Firefox, Chrome, Safari and, sometimes, Internet Explorer.


Monday 8th August 2011

Filed under: — Steve @ 10:16 am

Eric Scheffel has written a LatexRender plugin for WolfCMS. The plugin can be found at GitHub.

Online LaTeX review

Thursday 13th May 2010

Filed under: — Steve @ 12:56 pm

A review of online LaTeX can found in Daniel Stender’s blog Granthinam at Facets of current online LaTeXing.

Escaped characters in LatexRender

Tuesday 4th May 2010

Filed under: — Steve @ 10:21 am

LaTeX code uses backslashes for commands and sometimes this can be misinterpreted by PHP, particularly in more recent versions, giving strange and unwanted output (see here).  It is easy to adapt LatexRender code to deal with this problem and there are two articles, that I am aware of, showing how to do this:

Bill Baxter’s LaTeX in WordPress with PHP5.x

Ulf Hamster’s  Verwendung von LatexRender für Webpages  Google’s translation into English:  Use of latex rendering for web pages

Many thanks for these helpful articles. If you know of other articles that improve LatexRender do let me know.

Comparison of online compilers

Wednesday 18th November 2009

Filed under: — Steve @ 9:12 pm

Comparison of free, on-the-fly, web based LaTeX equation compilers compares some of the services mentioned in Online LaTeX which offer compilation via a URL.

A couple of the services are unable to process the plus sign correctly, probably because the symbol is changed at some stage. In those cases + needs to be replaced by %2B, thus

<img src=" = \displaystyle\sum^p_{j=1}\phi_jz_{t-j}%2B\sigma_\epsilon\xi_t" alt="" />

<img src=";tex=z_t = \displaystyle\sum^p_{j=1}\phi_jz_{t-j}%2B\sigma_\epsilon\xi_t" alt="" />

Similar changes may have to be made for other symbols, though it would be better if the services themselves could do the necessary translation.

Online LaTeX PDF

Wednesday 4th November 2009

Filed under: — Steve @ 7:04 pm

I have added a PDF of the post Online LaTeX. It can be downloaded here or in a link in the post or from the Downloads section on the right.

The number of links keeps growing and I’ll try to add new ones as they arise.


Friday 28th August 2009

Filed under: — Steve @ 11:07 pm

LatexRender has been adapted to many uses such as the hosted blogs at One new version is LatexRender-ng. One of its features is that it can output images in Scalable Vector Graphics (SVG) format. This has the advantage of allowing the images to be scaled as well as being faster to load than PNGs or GIFs. Unfortunately this is not well supported by Internet Explorer.

Poor GIF output in LatexRender

Filed under: — Steve @ 6:18 pm

John Forkosh (author of mathTeX) has brought to my attention a bug in the latest version of ImageMagick’s convert. This is used to produce the gif image and can result in poor output with very light fonts. If you get this you can get a better result with LatexRender if you convert to a png instead.

In class.latexrender.php look for the line
var $_image_format = "gif"; //change to png if you prefer
and change it to
var $_image_format = "png";

You could instead use an older version of ImageMagick (such as version 6.2.9) or bypass ImageMagick altogether with dvipng, which is the method that uses.

Discussion of this problem can be found here. Let’s hope the bug is resolved in the near future.

Long LaTeX posts in

Tuesday 25th August 2009

Filed under: — Steve @ 7:52 pm

LaTeX2WP, written by Luca Trevisan, is a Python script that will convert a LaTeX file into a format suitable for pasting into a post. uses its customised version of LatexRender to render the snippets of LaTeX, but LaTeX2WP will help prepare long texts. LaTeX2WP takes a TeX file and reformats it adding the required HTML codes and latex tags so that you can have, for example, numbered equations and dispayed equations. This is particularly useful for long mathematical notes containing lots of mathematics. It’s used by, amongst others, the Fields medallist Terence Tao for his blog at What’s new.

You can read more about LaTeX2WP and download it from LaTeX to WordPress

MathTeX Web Service

Monday 11th May 2009

Filed under: — Steve @ 2:23 pm

As mentioned before in mathTeX helper, mathTeX is a good way of generating high-quality LaTeX images for your site. mathTeX web service is a very useful way of using mathTeX without having to install LaTeX on a server and a couple of sites offer ways of using this service.

  • Latex Math is a WordPress plugin enabling you to add LaTeX code to your WordPress blog;
  • Webtop Mania has a Mathtex bookmarklet which gives you a prompt to add LaTeX code.

Installing \LaTeX on a hosted site

Friday 27th June 2008

Filed under: — Steve @ 11:08 am

Many \LaTeX users have no root access to the server running their web site, which makes it difficult to install \LaTeX, unless their hosts can be persuaded to do so. However, if you have shell access to your account you may be able to install \LaTeX in your home directory. Instructions are at Installing LaTeX on Web Hosts (32 bit Linux) and Installing latex on HostMonster (64 bit Linux).

CodeCogs Equation Editor

Monday 11th February 2008

Filed under: — Steve @ 11:35 am

LaTeX Equation Editor is an innovative editor with a symbol table for those who are not sure of the LaTeX code as well as allowing the code to be typed directly. It uses Ajax so that the page does not need to be refreshed to see the rendered image.

This equation editor can be used in a number of ways:

    1. Create the equation and then copy and paste the image into your website;
    2. Fetch the code directly from CodeCogs site and use in your website like this
    <img src="\tiny \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }" /> which gives

    3. Incorporate the visual editor into your text box (for example in a forum such as phpBB) or the FCK Editor;
    4. Install the complete system on your server.

Method 1 does not require any code, method 2 only requres a small amount of HTML and is particularly suitable for example for Blogger. Method 3 needs some PHP code on your site and method 4 requires LaTeX and other software to be installed on your server. Full instructions are provided at Installing the CodeCogs Equation Editor v2

Please note that if you use method 3 you should display the following banner on your page CodeCogs - An Open Source Numerical Library and if you use methods 2 or 3 then do please contact CodeCogs first at CodeCogs Services.
Do let CodeCogs know of any customisations or innovative uses that you make of their equation editor.

mathTeX helper

Monday 14th January 2008

Filed under: — Steve @ 5:49 pm

As mentioned in Online LaTeX mathTeX lets you incorporate high-quality LaTeX images in an web page using an image tag so
<img src="\sqrt{a^2+b^2}" />
becomes which may be placed slightly too high on the line.

This is very simple to do but remembering exactly what to type can be a problem, particularly in sites like Blogger. So I have written a tool which

  • allows you to test LaTeX code first
  • creates the image code (or URL with a link if you prefer) automatically for you
  • adds title attributes so that hovering a mouse over the image shows the code
  • ensures that the image’s vertical spacing is improved

This makes it simple to produce c=\sqrt{a^2+b^2} whose code is
<img src="\sqrt{a^2+b^2}" title="c=\sqrt{a^2+b^2}" alt="c=\sqrt{a^2+b^2}" style="vertical-align:-2pt;" />

Download mathTeX helper which runs on your own computer and uses JavaScript.

Online LaTeX 2

Monday 4th June 2007

Filed under: — Steve @ 5:26 pm

As mentioned in the previous post mimeTeX parses a LaTeX maths expression and immediately emits the corresponding gif image. All you need do is write <img src="\sqrt{a^2+b^2}" /> and you get the mathematical formula. It’s beautifully simple.

Following a suggestion by John Forkosh, the author of mimeTeX, I would like to do the same for LatexRender to help those who don’t have access to a LaTeX enabled server. I am looking for volunteers who are willing to host LatexRender on a publically available server, accessed in a similar manner to mimeTeX’s server. I doubt that it would need huge bandwidth but it does need a commitment to be available for use.

Do let me know if you are interested and can offer such a service.

WordPress 2

Wednesday 4th January 2006

Filed under: — Steve @ 5:28 pm

I have tested LatexRender in WordPress 2 and it works fine.

If you use the default visual rich editor (it can be turned off in Your Profile) when posting you won’t see a tex button but that would also be true for all the other WYSIWYG editors you can use.

See Plugin Compatibility for a list of plugins that work with WordPress 2.


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
\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)
q := fullcircle scaled 2.5in;
fill q withcolor black;
clip p to q;
draw p rotated (90) withcolor white;[/illust]

Commutative Diagrams

Wednesday 29th December 2004

Filed under: — Steve @ 5:10 pm

These diagrams are drawn by Michael Barr’s diagxy package and are taken from the manual:
\square/>>`>`>` >->/[A`B`C`D;e`f`g`m]


A\twoleft B\twoleft^f C\twoleft_g D\twoleft^h_{{\rm Hom}(X,Y)} E


\cube|arlb|/ >->` >->`>`>/&lt;1000,1000>[A`B`C`D;f`g`h`k]%

More \LaTeX Graphics

Sunday 28th November 2004

Filed under: — Steve @ 6:42 pm

These graphics were taken from LaTeX Graphics

Triangle with circumscribed, inscribed, adjacent and Feuerbach circles

\begin{pspicture}*(420, 420)
  % Frame
  \pspolygon(0, 0)(420, 0)(420, 420)(0, 420)
  % Circumscribed circle and inscribed circle
  \pscircle[linecolor=blue](206, 222){166.18}
  \pscircle[linecolor=yellow](250, 197){75.42}
  % Adjacent circles
  \pscircle[linestyle=dashed, linecolor=green](476, 135){157.68}
  \pscircle[linestyle=dashed, linecolor=green](-32, -22){266.53}
  \pscircle[linestyle=dashed, linecolor=green](132, 579){315.92}
  % triangle
  \pspolygon(43, 253)(361, 283)(287, 77)
  % nine-points circle (Feuerbach)
  \pscircle[linestyle=dotted, linecolor=red](242, 195){83.09}


Plotting Graphs

Tuesday 31st August 2004

Filed under: — Steve @ 10:04 pm

\psplot[plotstyle=curve,linewidth=0.5pt]{-4}{0.9}{10 x exp}% postscript function
\psplot[plotstyle=curve,linecolor=red,linewidth=0.5pt]{-4}{3}{2 x exp}% postscript function
\psplot[plotstyle=curve,linecolor=blue,linewidth=0.5pt]{-4}{2.05}{2.7183 x exp}% postscript function
\rput(-4,-1){\color{white}bounding box\normalcolor}

These graphs are courtesy of PSTricks


Monday 30th August 2004

Filed under: — Steve @ 9:22 pm


Thanks to S.O.S. Mathematics CyberBoard for alerting me to the delights of the \LaTeX cancel package

\mbox{\Huge \pi}

Monday 9th August 2004

Filed under: — Steve @ 7:44 pm

\displaystyle \pi = \sum _{k=0} ^{\infty}  \dfrac{1}{16^k} \left[\dfrac{4}{8k+1}-\dfrac{2}{8k+4}-\dfrac{1}{8k+5}-\dfrac{1}{8k+6}\right]


Sunday 8th August 2004

Filed under: — Steve @ 11:54 pm

Now that the backslash eating problem is being resolved, I am hoping to produce a plugin which avoids editing WordPress files. Watch this space \displaystyle \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }

I’m testing

Thursday 5th August 2004

Filed under: — Steve @ 12:15 pm

I’m testing the \sqrt{2} and \dfrac{1}{2}


Wednesday 4th August 2004

Filed under: — Steve @ 7:27 pm

\displaystyle \int_{0}^{1}\frac{x^{4}\left( 1-x\right) ^{4}}{1+x^{2}}dx=\frac{22}{7}-\pi

\kappa =\dfrac{d\psi }{ds}=\dfrac{\dfrac{d^{2}y}{dx^{2}}}{\left( 1+\left( \dfrac{dy}{dx}\right) ^{2}\right) ^{\frac{3}{2}}}=\dfrac{\overset{.}{x}\overset{..}{y}-\overset{..}{x}\overset{.}{y}}{\left( \overset{.}{x}^{2}+\overset{.}{y}^{2}\right) ^{\frac{3}{2}}}


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