The distribution contains the following files:
- latex2wp.py: the conversion program
- latex2wpstyle.py: specifies typesetting options, and environments and macros recognized during the conversion
- readme.txt: some basic information on how to use LaTeX2WP
- terrystyle.py: sets the typesetting options in the style of Terry Tao’s blog.
- macrosblog.tex: defines LaTeX commands recognized by LaTeX2WP for typsetting colors, links to URLs, and images, so that LaTeX files containing such commands can be typeset and previewed offline
- example.tex: a sample post showing how to use the main functionalities recognized by LaTeX2WP
- post-template.tex: a starting point for writing a post in LaTeX; it imports various packages and macros so that pictures, hyperlinks etc. can be seen in the preview the same way they will appear in the post.
- knuth.png: a picture (from xkcd, Copyright Randall Munroe) required to preview example.tex
- gpl.txt: the text of the GNU General Public License
- changelog.txt: a list of changes from previous versions.
By looking at example.tex, it should be easy to see how to get started. Indeed, just starting to write LaTeX, and seeing what happens with the conversion should be fine.
Your mathematical posts do not have to look like mine. A number of stylistic changes can be made by editing latex2wpstyle.py (make a copy before editing it); comparing it to terrystyle.py, and reading the comments in the code, should help understand how to make such changes.
It is possible to add your own LaTeX macros, if they do not involve passing of parameters. It wouldn’t be too hard to add support for arbitrary LaTeX macros and environments, but right now I have run out of energy (maybe during the Summer).
Another limitation is that there is no support for footnotes, and no support for bibliographic references. I will definitely work on this during the Summer.
When LaTeX2WP cannot do what you want, you can always put HTML code in the scope of a \ifblog . . . \fi. The conversion will output such HTML code verbatim, and it will be ignored in the LaTeX preview. Conversely, anything in the scope of \iftex . . . \fi is compiled in the LaTeX preview but skipped in the conversion.

13 comments
Comments feed for this article
July 9, 2010 at 10:20 pm
A bash workflow script for LaTeX2WP « Christian Marks
[...] the script detects which operating system it is running on to determine whether to copy the LaTeX2WP html output to the pasteboard or the clipboard; it also reminds me which keystrokes to use on my [...]
October 4, 2010 at 9:26 pm
daFeda
Hi, is there a way to write equations such that they appear centered in WordPress? I’ve tried using both \[ 'equation' \] and \begin{equation} \end{equations} without luck.
Thanks.
November 18, 2010 at 8:08 pm
Luke Grecki
WordPress seems to be changing the html I get from latex2wp. I’ve only had a problem starting today. I was able to make two posts using latex2wp html that turned out perfect. Strangely, even when I post the html of one of these old successful posts into a new draft post wordpress still changes it.
In particular it seems they are removing some of my ‘s, which results in my boxes surrounding way more text than they should.
November 18, 2010 at 8:15 pm
Luke Grecki
In my above comment the last sentence was meant to be
“In particular it seems they are removing some of my div code for boxes, which results in my boxes surrounding way more text than they should.”
July 27, 2011 at 9:40 am
First Draft | Eigenpost
[...] accept LaTeX code directly, albeit somehwat cantankerously. Thankfully, Luca Trevisan has written LaTeX2WP, a Python script that will take a LaTeX document and convert it into HTML, complete with modified [...]
December 30, 2011 at 9:43 am
$latex LaTeX$ na WordPress – porada « FIKSACJE
[...] Tak więc polecam – może warto wypróbować – konto na WordPress jest za darmo a posty – jeśli ktoś ma depresję i jest człowiekiem pozbawionym wrodzonego entuzjazmu – mogą pozostać prywatne! Skrypt o którym mowa można pobrać na tej stronie, zaś instrukcja jego używania znajduje się tuż obok. [...]
December 30, 2011 at 11:12 am
LaTeX na WordPress – porada « FIKSACJE
[...] Tak więc polecam – może warto wypróbować – konto na WordPress jest za darmo a posty – jeśli ktoś ma depresję i jest człowiekiem pozbawionym wrodzonego entuzjazmu – mogą pozostać prywatne! Skrypt o którym mowa można pobrać na tej stronie, zaś instrukcja jego używania znajduje się tuż obok. [...]
May 16, 2012 at 8:23 pm
Sumit Kumar Jha
It is giving the following error:
Traceback (most recent call last):
File “E:\latex2wp.py”, line 657, in
s=extractbody(s)
File “E:\latex2wp.py”, line 140, in extractbody
for i in range(1,(len(L)+1)/2) :
TypeError: ‘float’ object cannot be interpreted as an integer
July 18, 2012 at 10:18 pm
De Latex a WordPress « Memorandum Matemático
[...] Si necesitas personalizar la salida o tener mayores detalles de su funcionamiento, recomiendo leer aquí. [...]
August 30, 2012 at 7:31 am
augustusvandusen
I am getting the same error as Sumit Kumar Jha.
September 4, 2012 at 2:59 am
augustusvandusen
The program works with python 2.7.3 but not with 3.2.3. At least this is the case on my windows 7 machine.
November 16, 2012 at 7:54 am
hugo
i get the same error as sumit kumar jha, i.e. the html file isn’t even created.
May 6, 2013 at 8:31 am
子元 (@ziyuang)
I’ve ported it to Python 3, feel free to comment and patch. https://github.com/ziyuang/latex2wppy3