LaTeX in Wordpress

What is LaTeX?

The LaTeX project web page defines it as “a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation. LaTeX is the de facto standard for the communication and publication of scientific documents.” For instance, a person using LaTeX is able to easily typeset complex mathematical equations, including special characters, accent marks, subscripts, superscripts, fractions, etc. LaTeX is free software, and is licensed under the LaTeX Project Public License. LaTeX is extremely well documented, and the project’s home page can be found here.

What is Wordpress?

The Wordpress project web page defines it as “a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability.” In simpler words, Wordpress is a blogging software package. Wordpress is an open source project, which means that it is free to use. The software is licensed under the GNU General Public License. Wordpress is also an extremely well documented piece of software, and the project’s home page can be found here.

Is it possible to use LaTeX with Wordpress?

Yes, this is possible, and it is the focus of the following documentation.

Why would I want to use LaTeX with Wordpress?

Using LaTeX with Wordpress enables bloggers to include technical typesetting within their blog. For instance, using LaTeX with a Wordpress blog allows the user to include complex mathematical formulas within blog posts.

What is the easiest way to currently use LaTeX with Wordpress?

The easiest way to use LaTeX with Wordpress is to set up a free blog through Wordpress.com. Every blog on Wordpress.com automatically supports LaTeX. You can read about this functionality here. If you haven’t already set up a blog and are interested in being able to use LaTeX with Wordpress, this option will have the least time consuming setup. It is highly recommended for inexperienced users.

What if a web hosting company hosts my website, can I use LaTeX with Wordpress then?

Yes, you can, but the setup is generally more complicated than setting up a blog through Wordpress.com. If you fall under this category, here is a set of steps that should allow you to setup LaTeX with Wordpress:

  1. Make sure that your web hosting company has LaTeX installed on the server that hosts your website. Most professional hosting companies will already have LaTeX installed before you ask them about it. Contact them to make sure that a typical installation of LaTeX is present on the server. If the web hosting company is unable or unwilling to install LaTeX for you, you have the options of either hosting your own website or setting up a free site through Wordpress.com.
  2. Make sure that your web hosting company has ImageMagick installed on the server that hosts your website. Again, most professional hosting companies will already have this installed before you ask. Contact them to make sure it’s present on the server. Like I said in step 1, if this software can’t be installed on this server then you won’t be able to use LaTeX with Wordpress in this particular way. ImageMagick is free software used (in this case) to convert LaTeX output (a postscript file) into a picture files (GIFs) that can be used in your blog posts.
  3. I suggest that you have at least Wordpress 2 installed. If you have a previous version of Wordpress installed, I suggest visiting the Wordpress upgrade instructions here. Be sure to follows these instructions closely if an upgrade is needed.
  4. Download the LaTeXRender plugin here. This is a Wordpress plugin that has been designed to enable a fairly easy setup of LaTeX with Wordpress. When you unzip this wp-latexrender.zip file there will be 11 files in the folder that are created. You will need to modify the two files named latex.php and class.latexrender.php for the remainder of this tutorial. You will also need the latexrender-plugin.php file.
  5. Connect to your server and find the location of your Wordpress files. Wherever this location is, create a new folder here named “latexrender”.
  6. Within this latexrender folder create two subfolders named “tmp” and “pictures”. Once these subfolders are created you must change their permissions so that they are both readable and writable. In many cases, you can right click on each of the folders and choose to change the permissions or security settings for the folders. There is always a number associated with the amount of permissions that you’ve granted for a file. The number that these folders need to be set to is “777″. This number will allow these folders to be both readable and writable.
  7. Open the latex.php file. Find the lines $latexrender_path = “/home/domain_name/public_html/path_to/latexrender”; and $latexrender_path_http = “/path_to/latexrender”;. You’ll need to change these two lines to reflect the location of the latexrender folder you created in step 5. As the dummy paths should indicate, the latexrender_path_http path is a subset of the latexrender_path.
  8. Open the class.latexrender.php file and find the four lines var $_latex_path = “/usr/bin/latex”; var $_dvips_path = “/usr/bin/dvips”; var $_convert_path = “/usr/bin/convert”; var $_identify_path = “/usr/bin/identify”;. These lines need to be changed to reflect the locations of various utilities that take part in rendering the LaTeX picture files that you’ll use within your blog. If these path names don’t look familiar to you, I suggest that you contact your web hosting company to ask what these paths should be. For many people these default values should be correct without having to edit them.
  9. Open the latexrender.plugin.php file and find the line include_once(’/home/path_to/wordpress/latexrender/latex.php’);. You’ll need to change this line to reflect the location your latex.php file.
  10. You have the option of allowing those who leave comments on your Wordpress blog to use LaTeX within their comments. This option isn’t allowed by default. If you’d like to enable this ability, find the line //add_filter(’comment_text’, ‘addlatex’); in the latexrender-plugin.php file and remove the // at the beginning of this line.
  11. Upload the latexrender-plugin.php file to the plugin folder of your Wordpress installation (generally wp-content/plugins) and activate the plugin via the Wordpress administration panel.
  12. If everything is configured correctly LaTeX should now be setup for use with Wordpress! Any text in a Wordpress post surrounded by the tags [tex ] and [/tex ] will be rendered by LaTeX! (Remove the spaces in the tags. I’ve only included them so that they aren’t actually rendered by LaTeX.)

What if I host my own website, can I use LaTeX with Wordpress then?

Yes, you can, but the setup is perhaps the most complicated out of the three possible LaTeX options I’ve presented here. This option requires that you install LaTeX on your server before configuring Wordpress to work with it. Since installation of LaTeX is beyond the scope of this documentation, I suggest searching the LaTeX project web page for primers on how to get started.

Generally speaking, the particulars of your LaTeX installation will be dependent on your server’s setup. There are many existing tutorials on how to setup LaTeX under Windows, Mac OS X, various Linux distributions, etc. Once you’ve verified installation of LaTeX on your server, you can follow the directions listed in the previous question, “What if a web hosting company hosts my website…?”

Or…

Gunnlaugur Þór Briem has written a wonderful LaTeXRender installation script that can be found here. If you follow the directions on his site you may be able to install LaTeXRender even faster than with the directions given in the previous section.

Special thanks

Steve at SixthForm: He is the individual who made this LaTeXRender for Wordpress reality. Please click on his site to view more specific troubleshooting advice as well as added LaTeX functionality.

Gunnlaugur Þór Briem at Fugato: He is the individual who created the LaTeXRender installation script mentioned in this documention.

Kudos to both of them! They deserve a ton of credit! They’ve done most of the heavy lifting. I’m merely trying to organize some information.

(This documentation was last updated on 5.9.07. If you have any suggestions or updates, please send them to me through the contact me page.)

\rho=\gamma \times \omega
just testing

How can I install the Plugin under Wordpress 2.5

I suggest attempting to follow the directions listed above, and to check out the links above. I will let you know that I currently have this plugin working in Wordpress 2.5, so it’s definitely possible. Check it out:

\displaystyle\frac12 < \left\lfloor \mathrm{mod} \left( \left\lfloor \frac{y}{17}\right\rfloor 2^{-17\lfloor x\rfloor -\mathrm{mod}(\lfloor y\rfloor , 17)},2\right)\right\rfloor

Thanks to Fugato for the above mathematical wonderfulness.