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

mathcache

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.

## 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.

## 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.

## 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

Sitmo
<img src="http://www.sitmo.com/gg/latex/latex2png.2.php?z=100&eq=z_t = \displaystyle\sum^p_{j=1}\phi_jz_{t-j}%2B\sigma_\epsilon\xi_t" alt="" />
gives

MathTran
<img src="http://mathtran.open.ac.uk/cgi-bin/mathtran?D=1;tex=z_t = \displaystyle\sum^p_{j=1}\phi_jz_{t-j}%2B\sigma_\epsilon\xi_t" alt="" />
gives

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

## Wednesday 4th November 2009

Filed under: — Steve @ 7:04 pm

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 WordPress.com. 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 WordPress.com uses.

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

## 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 WordPress.com post.

WordPress.com 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.

## 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.

## Friday 27th June 2008

Filed under: — Steve @ 11:08 am

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

## 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="http://www.codecogs.com/eq.latex?\tiny \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }" /> which gives
$\tiny \int_{-\infty }^{\infty }e^{-x^{2}}\;dx=\sqrt{\pi }$
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  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.

## 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="http://www.forkosh.com/mathtex.cgi?c=\sqrt{a^2+b^2}" />
becomes $c=\sqrt{a^2+b^2}$ 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="http://www.forkosh.com/mathtex.cgi?c=\sqrt{a^2+b^2}" title="c=\sqrt{a^2+b^2}" alt="c=\sqrt{a^2+b^2}" style="vertical-align:-2pt;" />

## 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="http://www.forkosh.dreamhost.com/mimetex.cgi?c=\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.

## 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 \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]

## 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:

## 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

## Tuesday 31st August 2004

Filed under: — Steve @ 10:04 pm

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 cancel package

## Monday 9th August 2004

Filed under: — Steve @ 7:44 pm

## 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

## Thursday 5th August 2004

Filed under: — Steve @ 12:15 pm

I’m testing the and

## Wednesday 4th August 2004

Filed under: — Steve @ 7:27 pm

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