LaTeX2WP is a program that converts a LaTeX file into something that is ready to be cut and pasted into WordPress.
This way, you can write, and preview, your post in LaTeX, then run LaTeX2WP, and post into WordPress whatever comes out.
Why would you want to do that? Most users of WordPress wouldn’t.
But if you have ever found yourself typing
<p align="center"> $ latex \displaystyle \mathop{\mathbb E}_{x\sim X} f(x):= 1 \ \ \ \ (1)&fg=000000$ </p>
in order to get
and wondered whether there is a better way, maybe this is for you.
WordPress does a good job supporting simple LaTeX expressions. You type $ latex 2^{2^k}$, and out comes . There are, however, some inconveniences if you are typing something more complex:
- The editor windows is small, and it can be slow to save and produce a preview;
- Simulating LaTeX’s displayed equations is a bit painful. If one wants to have numbered equations, they have to be numbered by hand; if one wants to insert one more equation or rearrange the order of presentation, equations must be renumbered by hand, and so do all references to equations;
- If one wants to publish the notes/ expositions posted on WordPress, then one needs to convert them back to LaTeX.
There are also smaller concerns: for example some WordPress themes (including in theory’s one) typeset LaTeX equations in gray. This can be changed by appending &fg=000000 to every formula, which is nice to automate. If you are used to having simple macros like \E for expectation, it is annoying to have to type {\mathop{\mathbb E}} each time.
With LaTeX2WP you write your whole post in LaTeX, and use LaTeX to preview it. You cannot use arbitrary macros, but any macro that can be implemented by a simple substitution can be easily added. Any set of theorem-like environments such as theorem, lemma, proposition, remark, etc. can be defined, with any combination of counters. Displayed equations are automatically numbered and centered, and all math equations are typeset with black fonts. The LaTeX commands \label, \ref and \eqref are supported, and \ref and \eqref translate to clickable links. You also maintain a LaTeX source for your post, which is ready for publication in another venue.
So far LaTeX2WP has been used at what’s new and here, at in theory. You’ll notice that the typesetting styles for theorems and section names look different. It is easy to modify the typesetting options to suit your own taste.
I would like to thank Terry Tao with his patience while using a very buggy early version and suggesting several useful improvements.
LaTeX2WP is distributed as free software with a GPL 3 license.
(More or less, this means that you can do with it whatever you like. If you create and distribute a modified version, however, you must distribute it as free software under the same GPL license and credit me for having written the original version.)
If you would like to try it out, click the download tab. If you would like to learn more about the features and limitations of LaTeX2WP, or if you are using it and have a question or a bug report, click the using LaTeX2WP tab.
If you end up using it, do let me know, by commenting on this page or by sending an email to LaTeX2WP at gmail dot com. Do include a link to your blog.

66 comments
Comments feed for this article
February 21, 2009 at 1:59 pm
Converting LaTeX to WordPress « in theory
[...] LaTeX to WordPress [...]
February 21, 2009 at 7:13 pm
atri
Luca,
This sounds great. Thanks for making this available. I maintain a blog for my coding theory course and the limitations of wordpress LaTeX support has been somewhat annoying. I’m looking forward to using your program to make my life much easier. Thanks again.
February 21, 2009 at 11:20 pm
Geoff Briggs
Excellent! Would you consider licensing this under GPL V2 or GPL V2+? Some people at big companies (e.g. Microsoft) can’t contribute to GPL3 software because of its terms regarding patents.
February 22, 2009 at 9:39 am
rjlipton
I will try this out. Looks really like great idea…dick
February 23, 2009 at 8:55 am
Dima
Cool! I’ll give it a try, definitely.
etc etc.
Meanwhile, I have invented my own little hack to type maths in WP by using an external editor (vim in my case) that is called up by a Firefox plugin called It’s all Text, and where I have few pre-defined abbreviations to speed up the typing, e.g. $$ to type “$ latex”, i.e. the beginning of LaTeX formula, ZZ for the proper mathbb symbol for
February 25, 2009 at 4:56 pm
ccarminat
I think I have found some bug: I typed
\begin{document}
$\Phi:I_1 \to I_2$
$$\Phi \circ T_1=T_2\circ \Phi$$
\end{document}
But I obtained
I would call it the phi-bug
February 25, 2009 at 5:17 pm
luca
You are right, it’s because the substitution rule used to render \P as
is applied to every occurrence of ‘\P’ even if \P is followed by other alphabetic characters, and so is a different LaTeX command. I’ll fix this in the next revision (which should be coming out by the end of the week)
February 25, 2009 at 10:33 pm
ccarminat
Grazie mille, e buon lavoro!
c.c.
February 27, 2009 at 11:57 pm
Kevin L
Thank you!!! This is wonderful!
March 1, 2009 at 4:45 pm
LaTeX2WP Update « in theory
[...] LaTeX to WordPress [...]
March 3, 2009 at 11:21 pm
580 -Cardinal arithmetic (7) « Teaching page
[...] -Cardinal arithmetic (7) [This document was typeset using Luca Trevisan's LaTeX2WP. I will refer to result (or definition ) from last lecture as [...]
March 3, 2009 at 11:33 pm
andrescaicedo
Hi,
I just made public the first post I wrote using your program. Thank you very much! You have saved me hours already. (The link in the previous comment is from the blog.)
There were a few (minor) strange anomalies during the conversion:
1. The first two lines disappeared; instead, it only appeared “Luca Trevisan” (and a link).
2. I had a definition by cases that refused to compile. I have used the LaTeX array command in previous posts, so I am not sure what the issue was.
3. The last line from paragraph -7 disappeared.
4. A few things were supposed to appear in blue, but didn’t.
(I am not sure whether I should have posted the bugs here or in the entry for Using LaTeX2WP; sorry.)
March 3, 2009 at 11:42 pm
luca
Andres: I am happy the program (sort of) works for you.
I wonder what causes the problems you had. If you send me the LaTeX source (at the address latex2wp at gmail dot com) I could try to replicate those anomalies and understand what caused them.
March 4, 2009 at 12:34 am
305 -5. Extensions by radicals « Teaching page
[...] -5. Extensions by radicals (This post was typeset using Luca Trevisan’s LaTeX2WP [...]
March 15, 2009 at 7:37 pm
Hardness of approximation - Lecture 1 « Expanders, Property Testing and the PCP theorem
[...] am typing this lecture to test Luca Trevisan’s latex2wp converter. I probably won’t have the time to type lectures any more this semester. Here’s a brief [...]
March 21, 2009 at 11:07 am
Only A Test « Mr Toms MathPhys Extravaganza
[...] Only A Test By tomdickens This is simply a test of the Latex to WordPress converter available here. [...]
April 3, 2009 at 6:55 am
ateixeira
Hi there! Finall I manged to get the time to finish my post using your program and I have to say that it came out very good. The only down side is that I had to change my theme. I used to have a black background theme but since the text in theorem-like environments grayish it’d been harder to read for my two or three usual readers. I tried to understand why this was so but couldn’t solve the problem and just changed the theme.
Anyway thanks a lot for providing us with a tool that makes math easier on WordPress.
http://climbingthemountain.wordpress.com/2009/04/03/real-analysis-limits-and-continuity/
April 3, 2009 at 2:50 pm
Academic Career Links
Thanks! Great stuff!
April 6, 2009 at 1:44 pm
ateixeira
Just to tell you that I managed to bet back to my old theme since I could sort out the html code in order to get tables around my theorem like environments.
Once again thanks a lot for this tool.
April 8, 2009 at 7:53 pm
rjlipton
I thank you for this program. One issue math inline seems to be typeset below the line more than it should. Is that a wordpress issue or is that something we can fix?
April 16, 2009 at 1:29 pm
ratnuu
Excellent script suit. I was so annoyed by the wordpress message ‘unable to parse the equation’,until I hit upon this site. This did wonders to me. Thank you so much for sharing the script.
I am looking forward to have tikz/pgf supported as well:-)
Best regards
R
May 12, 2009 at 9:01 am
Welcome « VeRTEx
[...] int_{a}^{b} f(x) dx = frac{pi}{2}” yields . There is also a LaTex-to-WordPress converter here which could be [...]
May 18, 2009 at 2:03 pm
pablolessa
Thank you very much for this great program.
¿Is it posible to set latex2wp up so that it works with a utf-8 source file? Since I write primarily in spanish it’s a minor inconvinience to have to add the accents later… Typical example: “demostración” converts to “demostración”.
Thank you once again.
May 20, 2009 at 8:48 am
LaTeX2WP minor update « in theory
[...] LaTeX to WordPress [...]
May 22, 2009 at 9:53 am
ateixeira
To pablolessa:
You can use the Spanish option of the babel package.
Some texts that I write in Portuguese are done that way and I’m not having any problems with accents so far.
May 25, 2009 at 12:14 pm
About the Blog « Math Questions
[...] http://lucatrevisan.wordpress.com/latex-to-wordpress/ [...]
July 24, 2009 at 8:21 am
An interesting inequality due, perhaps, to Kashin « Mathematical Remarks
[...] to Kashin Published July 24, 2009 Analysis Leave a Comment In order to test the latex2wp software, I’ve dug out an old file and will post it here. There might be something [...]
July 26, 2009 at 4:40 am
O displaystyle do LaTeX permite uma melhor visualização no WP « problemas | teoremas
[...] acrescentar, no fim, a todos, o código &fg=000000 , como é explicado, por exemplo, em LaTeX to WordPress do blogue ” in theory [...]
July 28, 2009 at 11:35 am
Latex2wp Example.html « random terrain
[...] look like on wordpress, when you have converted the ‘example.tex’ file provided with Latex to WordPress to html using the program. Look at the document source to see how to strike out text, how to use [...]
July 31, 2009 at 8:09 pm
Mark Lewko
As requested above, I am using LaTeX2WP over at lewko.wordpress.com. I’ve been very happy with it.
August 4, 2009 at 5:29 pm
Akhil Mathew
I’ve been using LaTeX2WP and find it quite useful when contributing to the Delta Epsilons group blog (deltaepsilons.wordpress.com).
Thanks for making it available!
August 26, 2009 at 7:40 pm
Octavian
Dear Luca, thanks for your work.
But actually I know nothing about python. When I write pyhton latex2wp.py example.tex in the command line, I read this message:
File ‘”, line 1
python pyhton latex2wp.py example.tex
^
SyntaxError: invalid syntax
Help me, please…
August 30, 2009 at 8:55 am
ateixeira
Hi Octavian!
Have you made any change in the files provided by Luca? I think that’s why you’re getting a syntax error.
http://climbingthemountain.wordpress.com/about/
September 2, 2009 at 2:02 am
Uwe Stroinski
First of all: Great tool! I am currently trying it and have two observations:
1) \noindent is noz recognized
2) \newcommand does not parse
Any idea? Especially on the second? Thx in advance.
September 2, 2009 at 12:03 pm
luca
I’ll add \noindent in the next release, but \newcommand is not coming any time soon.
September 4, 2009 at 4:09 pm
Lect 3: Stable Marriage Problem « Introduction to Algorithm Analysis and Design
[...] Lect 3: Stable Marriage Problem (This post is typeset using LaTeX2WP) [...]
September 8, 2009 at 11:30 pm
Uwe Stroinski
A couple more observations of no real practical concern, but probably nice to know:
1) \nonumber is not supported
2) paragraphs before and after \begin{description} seem to get deleted occasionally.
3) \usepackage[all]{xy} is not supported (that seems to be WordPress)
The output in my blog currently looks ‘Taoesque’. How can one steer that more towards ‘in theory’ style? Is this because of the &fg=000000? A small hint would suffice. Thx.
September 9, 2009 at 10:05 pm
leandromat
Awesome !!!!
Thank you very much, for let available the LaTeX2WP program.
September 19, 2009 at 3:15 am
ugroh
Luca, the program is great. Thank you for it.
My question: Since I am publishing in German, I would like to habe “Satz” instaed of “Proposition” e.q. I tried to chace it in macrosblog.tex
\newtheorem{proposition}[theorem]{Satz}
no result. Then I worked through latexwpstaly.py, but I don’t know how th chance it there. Al what I have done produced error messages.
Is this coded soemwehre else? Can you please help me?
Thanks
Ulrich
September 19, 2009 at 3:36 am
ugroh
.. forget the question. I got it reading more carefully the README file.
Ulrich
September 19, 2009 at 1:32 pm
Mithrandir
Does it know how to render source code?
September 20, 2009 at 12:40 am
Shalin Mehta
Dear Luca,
This is an excellent tool! I have a feature request. Is it straight-forward to have fixed-width columns in a tabular environment? I mean the p{width} or m{width} type columns in standard latex tabular environment. I am typesetting a table for my blog for which I need it.
best
Shalin
September 21, 2009 at 12:26 am
Shalin Mehta
I have ended up typesetting two pages with this script.My home page at http://shalin.wordpress.com and a post http://wp.me/p8BPt-4d. The M variable in latex2wpstyle.py seems like the key to extension. I want to add support for font-sizes and typesetting of code. I tried adding following substitution strings:
["\\begin{verbatim}","
"], ["\\end{verbatim}",""],
["\\begin{large}",""],
["\\end{large}",""]
But nothing happens. It seems every environment that is not listed in theorem-type environments in latex2wpstyle.py is ignored. Is that true? Is there a straightforward way of adding support for the above.
Once again, thanks.
Shalin
September 21, 2009 at 12:31 am
Shalin Mehta
Oh, the interesting bits were interpreted out. Following is what I tried. per=pre, sapn=span.
["\\begin{verbatim}",""],
["\\end{verbatim}",""],
["\\begin{large}",""],
["\\end{large}",""]
September 21, 2009 at 12:33 am
Shalin Mehta
Alright, the angular brackets are a culprit. Removed them.
["\\begin{verbatim}","pre"],
["\\end{verbatim}","/pre"],
["\\begin{large}","span style=\"font-size:x-large;\""],
["\\end{large}","/span"]
September 28, 2009 at 9:10 pm
Feedback Statistics « Introduction to Algorithm Analysis and Design
[...] Feedback Statistics Sorry for being so late on this but I finally got around to making pie-charts of your responses to the second feedback form. The results are below the fold. (The text part below is typeset with LaTeX2WP.) [...]
October 6, 2009 at 7:36 pm
Project Proposal « Dynamic Programming and Stochastic Control
[...] to use directly if you have a lot of equations, so I recommend that you use for example the little converter LaTeX2WP written by Luca Trevisan. With this tool, you can use the same file to prepare a hard copy [...]
October 8, 2009 at 10:20 pm
Long LaTeX posts in WordPress.com « Math840's Blog
[...] 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. Hence you need Python, which is automatically embedded in Unix, Mac OS and Linux(all distributions), in your system. Just click the link to see the details and instructions. Please Make sure to download the latest version. [...]
October 9, 2009 at 7:55 am
Steven Heilman
Hi-
This converter is excellent thanks! I should begin posting articles regularly at:
http://bfrank.org/overeducated/
So far, I am doing footnotes and references manually, (I am not a clever enough programmer to code such things), so I hope this support will be provided at some point.
Thanks!
-Steve
October 15, 2009 at 11:27 pm
LaTeX nach WordPress – Der Schockwellenreiter
[...] LaTeX2WordPress (GPL) ist ein Programm, das LaTeX-Dateien zu irgendetwas umwandelt, das dann direkt per Copy & Paste in WordPress eingesetzt werden kann. Das Teil ist in Python geschrieben, sollte also überall dort laufen, wo ein einigermaßen aktueller Python-Interpreter exisitiert (Download). [Peter van I. per Email.] [...]
October 21, 2009 at 1:03 pm
Latex2WP « Ceterum Censeo
[...] Latex in WordPress ausprobieren möchte wird hier und dort [...]
October 29, 2009 at 10:52 am
Displaying mathematics on the Web « What’s new
[...] of LaTeX and convert it into a web page or vice versa, although tools such as Luca Trevisan’s LaTeX to WordPress converter achieve a heroic (and very useful) level of partial success in this [...]
October 29, 2009 at 2:30 pm
LaTeX to WordPress. Something for my col… « Paul M. Watson
[...] 10:30 pm on October 29, 2009 Reply Tags: web (657) LaTeX to WordPress. Something for my colleagues at the TSSG who regularly put proposal documents through a build [...]
October 30, 2009 at 9:44 am
porton
It would be great to also make automated conversion from LaTeX to some wiki formats (e.g. MediaWiki and wikidot.org). I think we are to add it in a future version of “LaTeX to WordPress”.
November 4, 2009 at 5:00 am
LaTeX in WordPress « A test
[...] a LaTeX file into code one can copy and paste into WordPress. I found this program at this blog: LaTeX to WordPress. The author provides a .zip archive with several files. The archive can be downloaded from here: [...]
November 4, 2009 at 2:54 pm
Displaying maths online, II « What’s new
[...] of tools for converting mathematics into web friendly formats (e.g. LaTeX2HTML, LaTeXMathML, LaTeX2WP, Windows 7 Math [...]
November 4, 2009 at 4:02 pm
peeterjoot
I didn’t end up using your script as is, because I’d already written one by the time I found this. I did borrow from it though and now use the p align center stuff that you did for my wordpress blog (http://peeterjoot.wordpress.com/)
My script, a version of which is here in case anybody else wants to use it is here:
http://sites.google.com/site/peeterjoot/math2009/tex2blog
(includes an option also for experimental conversion of latex to mathml output for blogger where javascript is allowed).
A couple differences from your script:
- I can’t grok the python used enough to modify yours to do more complex macro replacements, and cobbled together some using perl that mostly work.
- I require the latex be compiled since I use the .aux and .bbl files to generate equation numbers and bib contents.
November 6, 2009 at 9:27 pm
LaTex Example « Euler's maze
[...] Euler's maze a blog on neuroscience « Neuroanalysis by AVI PELED LaTex Example November 7, 2009 Copyright by LaTex to WordPress [...]
November 7, 2009 at 10:43 am
porton
Braces should be removed from the text, as in this example:
\documentclass{letter}
\begin{document}
{Braced}
\end{document}
In HTML generated by L2WP “Braced” is erroneously shown braced.
November 7, 2009 at 4:21 pm
porton
Please add at the beginning of your script:
#!/usr/bin/python
November 12, 2009 at 7:37 pm
hailtt
November 14, 2009 at 8:59 pm
LaTeX2WP, Princeton grad student seminar, and characteristic polynomial coefficients « A Day in the Life of a Wild Positron
[...] in order to test out Luca Trevisan’s LaTeX2WP converter, which can be downloaded for free here. (So this is my learn-how-to-use-the-program post). It will clearly be helpful for my own blogging [...]
November 21, 2009 at 9:52 pm
timur
To porton: There are tools such as latex2wiki and latex2qwiki. Google will reveal them immediately.
November 23, 2009 at 8:18 pm
Feedback 3 statistics « Introduction to Algorithm Analysis and Design
[...] Feedback 3 statistics (Most of the text was typeset using Luca Trevisan’s LaTeX2WP) [...]
November 24, 2009 at 12:01 am
QuickLinks vom 17. November bis zum 24. November — instant-thinking.de
[...] LaTeX to WordPress – is a program that converts a LaTeX file into something that is ready to be cut and pasted into WordPress. [...]
November 27, 2009 at 4:32 am
using latex for wordpress « Musings of a curious mind
[...] but never fear there is always google to rescue you. So I found this nice little program listed on Terence Tao’s blog which a latex-to-wordpress python file quite nifty! Well you also have to have the python shell [...]