QuickLaTeX: A LaTeX plugin for WordPress

[latexpage]
Reading through the chat page for the {TeX} Q&A site today, I stumbled upon a reference to QuickLaTeX. This is a plugin for WordPress to allow you to show LaTeX code in your page or blog. That’s not unique, but what is interesting is that it runs the LaTeX on the QuickLaTeX server, meaning that you don’t need LaTeX on your web host’s system. For me, that was immediately interesting as I don’t have a TeX installation on the host for this site. (It looks like QuickLaTeX is built using TeX Live 2010, so most packages should be available unless you are on the bleeding-edge.)

The system seems pretty easy to use. The plugin follows the standard WordPress model: download, install and activate. The plugin page gives some details on how to use it, but a few examples here will show off the power of the system. It’s possible to put something simple into the blog, such as

!\[ y = mx + c \]

and get
\[ y = mx + c \]
or something much more complex, like

!\begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=40] {cos(x)*cos(y)};
\end{axis}
\end{tikzpicture}

and get
\begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=40] {cos(x)*cos(y)};
\end{axis}
\end{tikzpicture}
All that is needed, beyond the plugin, is to put ![latexpage] at the start of the page. You can then escape any ‘raw’ LaTeX by prefixing the beginning with !, for example

!!\[ y = mx + c \]

is what I used for the first of my demos.

I don’t often find the need to post actual LaTeX examples in my blog, but the facility is certainly one I’m happy to have access to. The license for QuickLaTeX asks for a public link to their site, which seems like a small pay-off for a very handy service.

11 thoughts on “QuickLaTeX: A LaTeX plugin for WordPress

  1. [latexpage]
    Thank you for writing about QuickLaTeX!

    You can escape compilation of LaTeX shorthands by placing “!” just before them.
    E.g.: !!$...$, !![...], !![latex]...[/latex] or even !!begin{tikzpicture} ... end{tikzpicture}.

    As for your question:
    “You can also do entire pages of LaTeX, but I’m not quite clear just yet how that works out (after all, web pages need to be flexible, whereas rendering with QuickLaTeX ultimately results in images).”

    Plugin do gentle parsing of the page, handling only LaTeX commands. The rest of the page is not touched. So no flexibility is lost – only extended.

    Besides not all of the LaTeX processing results in image generation – e.g. next version 3.7.3 will support equation referencing by standard LaTeX rules. User can setup label for formula by label{}. Then !ref{} anywhere in the text will be replaced by hyper-link to referenced equation for easy navigation.

    All of this are targeted for smooth publishing of math pages on the web. Ideally without (or with very small) changes in offline LaTeX papers to be published.

  2. Thanks for the quick reply Pavel. I’ll edit my post a bit later today to make this clearer: as I said, I’ve only discovered the plugin today so there is p obviously much to learn.

  3. Documentation of plugin is still very scarce, feel free to contact me on any issue. Thanks for your interest!

    P.S.
    I’ve just released new version 3.7.3 with hyper-referencing – I would appreciate if you would use it in your tests.

  4. One thing I can’t seem to get to escape is the ‘latexpage’ instruction: simply putting ! + [ + latexpage + ] fails to work (hence splitting it up here!).

  5. Yes, [latexpage] cannot be escaped with “!” now. I’ll fix this soon.

    Could you use [latexpage] for escaping until then? Sorry for inconvenience.

    Just noticed, source code for the 3D plot example seems to be incomplete.

  6. Thanks Pavel: I’ve modified the source to get this right. (The reason the Tikz picture source was wrong was because I wasn’t sure when I wrote the post how to escape everything).

  7. Hi Joseph,

    I’ve noticed some misbehavior here: http://www.texdev.net/2009/10/22/automating-releases-to-ctan/

    Some parts of text from make files on the page got compiled by QuickLaTeX.

    I believe the reason is that you turned on switch “Use LaTeX Syntax Sitewide” on “Advanced” tab in QuickLaTeX admin page.

    In this mode QuickLaTeX compiles LaTeX tags on every page (regardless of [latexpage]), which could easily messed up pages not intended for formulas (e.g. where source code is shown).

    This mode is good for all-math sites.

    However it is better to activate QuickLaTeX selectively with [latexpage] on the mixed-type sites, where only some pages are intended to include formulas (along with “Use LaTeX Syntax Sitewide” turned off).

    P.S.
    QuickLaTeX 3.7.4 is available which includes proper escaping for [latexpage].

  8. Hi Pavel,

    No, I looked at the settings pages but did not change anything: the ‘Use LaTeX Syntax Sitewide’ slider is currently ‘off’. Something else must be us, I guess. In the Makefile these is a part that says $$NAME and [ $$? = 0 ]: could this be confusing QuickLaTeX?

    By the way, I wonder if typesetting should be disabled within <pre> blocks? Inside these, everything should be verbatim, and they are used for source code, so it would seem sensible to me.

  9. Oh, I see. Sorry for misleading you. I was sure ![ ... ] was the cause of the trouble – and I made wrong conclusion since it is valid only on LaTeX enabled pages or in sitewide mode.

    And yes, QuickLaTeX handled !$$ ... $$ anywhere on the site. It was one of the feature long ago – now it is outdated and I’ve just removed this from QuickLaTeX 3.7.4. without version change.

    Please reinstall it from WordPress plugin database.

    @”By the way, I wonder if typesetting should be disabled within blocks?”

    Yes, it is good idea. QuickLaTeX now is context-free parser. We need to move parsing on the server where we can do context-depended parsing using high-performance libraries, not PHP.

Leave a Reply