# Using LaTeX2WP

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.

## 21 thoughts on “Using LaTeX2WP”

1. Hi, is there a way to write equations such that they appear centered in WordPress? I’ve tried using both $‘equation’$ and \end{equations} without luck.

Thanks.

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

3. 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.”

4. Pingback: First Draft | Eigenpost

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

6. I am getting the same error as Sumit Kumar Jha.

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

8. @ziyuang I’ve tried to change the files so that subsubsections would be supported but with little success. Do you think you can give me a hand?

9. Hello,
I think this programme is pretty cool but it seems like both $$…$$ and $…$ are not working properly. I have read my html file, and found out that there are no
…..
part in html but instead the html file is already aligned in the centre. I have no idea how to fix this problem as I know nothing about python, so I am writing a comment here to possibly get a respond from you. (Moreover, hyperlink, colouring and attaching photo also have the same issue)

By the way, I am a Macbook user, with macOS Sierra, version 10.12 and as a python programme, I use terminal that is equipped in mac from the beginning

10. One thing that would be very useful is to work with \input from multiple files, but also work with tikzautomata (although that may be very difficult! :).