**[Using LaTeX2WP]**

Click here to download LaTeX2WP version 0.6.2, May 20, 2009

LaTeX2WP is written in Python, so you’ll need a Python interpreter.

(If you are using Linux/Unix or OS X, then you already have it. If you are running Windows, go here and get the Windows installer for 2.6.1)

Uncompress the files of the LaTeX2WP distribution in the directory in which you are going to write your posts in LaTeX.

(On OS X, double click on the file latex2wp.0.6.2.zip after saving it; on Linux `unzip latex2wp.0.6.2.zip`

. If your Windows machine says it doesn’t know what to do with a .zip file, get 7zip.)

Write your LaTeX post, say you call it `spam.tex`

. When you are done writing your post, type from the command line

`python latex2wp.py spam.tex`

This will produce a file `spam.html`

. Open it with a text editor, copy and paste it into the WordPress editor, and here is your post.

The file *readme.txt* describes some of the LaTeX features that are recognized by LaTeX2WP and those that are not. The file *example.tex* shows how to typeset in colors and include pictures and hyperlinks. It is easy to change the way theorems, section names, etc., are typeset, and to add simple macros. More about this on the Using LaTeX2WP page.

### Like this:

Like Loading...

Thank you very, very much!

It works well for me !

I have a quetion: Could the reader get the .tex and .pdf files from my blog?

thanks a lot!

Could the reader get the .tex and .pdf files of the ( some or all ) articles in my wordpress blog ?

thanks!

very awesome! a great contribution to the math online community, thanks!!!

Pingback: Latex in WordPress « Programming Resources

I’m having some trouble getting going with latex2wp.

My file is called general.tex and I consistently see

File “”, line 1

python latex2wp.py general.tex

^

SyntaxError: invalid syntax

Am I doing something silly wrong (I’m completely new to python and am running Windows so have downloaded and tried Python 2.6 and 2.7) or is there a deeper reason for this do you know?

It’s simply amazing man! Thanks a lot!

Pingback: LaTeX e Wordpress: LaTeX2WP | Incerteza em Princípio…

Pingback: LaTeX2WP « Polariton

I get this error:

python c:\python31\l2wp\latex2wp.py hw2sol.tex

Traceback (most recent call last):

File “c:\python31\l2wp\latex2wp.py”, line 657, in

s=extractbody(s)

File “c:\python31\l2wp\latex2wp.py”, line 140, in extractbody

for i in range(1,(len(L)+1)/2) :

TypeError: ‘float’ object cannot be interpreted as an integer

What’s wrong?

Hi–

i am using fedora and i am getting this error.. can you please help

Error: can’t open file ‘latex2wp.py’: [Errno 2] No such file or directory

Pingback: LaTeX to WordPress | Testisivu

Pingback: latex2wp, alustava testi | Testisivu

Pingback: Latex2wordpress « under the sun

Pingback: Latex in Wordpress « Procrastimatics

Pingback: From LaTeX to Wordpress « schlappohrhase

Pingback: LaTeX to WordPress (latex2wp.py) « Guzman's Weblog

Pingback: LaTeX to WordPress (latex2wp.py using terrystyle.py) « Guzman's Weblog

Pingback: $latex LaTeX$ na WordPress – porada « FIKSACJE

Pingback: LaTeX na WordPress – porada « FIKSACJE

I converted the example.txt file (part of the LaTex2WP distribution) with LaTex2WP and then pasted the ouput html file in the WordPress editor window. I then saved the draft and previewed the post but it did not work. I am seeing a lot of html code and LaTex equations that do not parse. Does LaTex2WP work with the free version of WordPress or do I need to purchase the WordPress upgrade to get it work.

It works with the free version hosted on wordpress.com

When you go to the editor window, you’ll notice that there is a tab that lets you choose between the “visual” editor and the “html” editor. You want to choose “html” editor before pasting.

Pingback: De Latex a WordPress « Memorandum Matemático

Pingback: Using Latex in WordPress | Statistical Signal Processing (SSP) Lab, IISc

Pingback: On blogging and Latex « M721: Index Theory

i get the same error as Vivek

\documentclass[12pt]{article}

\usepackage[pdftex,pagebackref,letterpaper=true,colorlinks=true,pdfpagemode=none,urlcolor=blue,linkcolor=blue,citecolor=blue,pdfstartview=FitH]{hyperref}

\usepackage{amsmath,amsfonts}

\usepackage{graphicx}

\usepackage{color}

\setlength{\oddsidemargin}{0pt}

\setlength{\evensidemargin}{0pt}

\setlength{\textwidth}{6.0in}

\setlength{\topmargin}{0in}

\setlength{\textheight}{8.5in}

\setlength{\parindent}{0in}

\setlength{\parskip}{5px}

\input{macrosblog}

\begin{document}

Look at the document source to see how to \sout{strike out} text, how

to \begin{red}use\end{red} \begin{green}different\end{green} \begin{blue}colors\end{blue},

and how to \href{http://www.google.com}{link to URLs with snapshot preview}

and how to \hrefnosnap{http://www.google.com}{link to URLs without snapshot preview}.

There is a command which is ignored by pdflatex and which

defines where to cut the post in the version displayed on the

main page\more

Anything between the conditional declarations {\em ifblog . . . fi}

is ignored by LaTeX and processed by latex2wp. Anything

between {\em iftex . . . fi} is processed by LaTex and ignored

by latex2wp.

\ifblog \begin{green}This green sentence appears only in WordPress \end{green} \fi

\iftex \begin{red}This red sentence appears only in the LaTeX preview \end{red} \fi

This is useful if one, in desperation, wants to put pure HTML commands

in the {\em ifblog . . . fi} scope.

\begin{lemma}[Main] \label{lm:main}

Let $\cal F$ be a total ramification of a compactifier, then

\begin{equation} \label{eq:lemma} \forall g \in {\cal F}. g^2 = \eta \end{equation}

\end{lemma}

The (modifiable) numbering scheme is that lemmas, theorems,

propositions, remarks and corollaries share the same counters,

while exercises and examples have each their own counter.

\begin{theorem} \label{th:ad} The ad\`ele of a number field is never

hyperbolically transfinite.

\end{theorem}

\begin{proof} Left as an exercise. \end{proof}

\begin{exercise} Find a counterexample to Theorem \ref{th:ad}.

\end{exercise}

\begin{exercise}[Advanced] Prove Lemma \ref{lm:main}. \end{exercise}

Note that accented characters are allowed. Unfortunately,

Erd\H os’s name cannot be properly typeset in HTML.

(Note that to get the above approximation, you need to type

backslash-H-space-o, rather than backslash-H-{o}. Both are

good in LaTeX, but only the second is recognized by LaTeX2WP.)

One can correctly type the names of H\aa stad, Szemer\’edi,

\v{C}ech, and so on.

It is possible to have numbered equations

\begin{equation} \label{eq:test} \frac 1 {x^2} \ge 0 \end{equation}

and unnumbered equations

$$ t(x) – \frac 12 > x^{\frac 13} $$

Unnumbered equations can be created with the double-dollar sign

command or with the backslash-square bracket command.

\[ f(x) = \int_{-\infty}^{x} \frac 1 {t^2} dt \]

It is possible to refer to equations and

theorems via the {\em ref}, {\em eqref} and {\em label} LaTeX

commands, for example to Equation (\ref{eq:test}),

to Equation \eqref{eq:lemma},

and to Lemma \ref{lm:main} above.

eqnarray* is supported, but not eqnarray:

\begin{eqnarray*}

f(x) & < & x^2 – y^2\\

& = & (x+y) \cdot (x-y)

\end{eqnarray*}

{\em You {\bf can} nest a {\bf bold} text inside an emphasized

text or viceversa.}

The theorem-like environments {\em theorem}, {\em lemma},

{\em proposition}, {\em remark}, {\em corollary}, {\em example}

and {\em exercise} are defined, as is the {\em proof} environment.

The LaTex commands to type \$, \%, and \&\ are supported outside

math mode, and \%\ and \&\ are supported in math mode as well:

\[ 30 \& 10 \% \]

The section symbol \S\ is also supported.

WordPress has trouble if a LaTeX expression containing a $<$

symbol, such as $x^2 $ symbol, such as $(x+y)^2 > (x+y)^2 – 3$. This

is fixed by converting the inequality symbols into “HTML

character codes.” Always write the symbols $$ in

math mode.

It it is possible to have tabular environments, both with borders

(the border will not be displayed in the LaTeX preview), as in

\begin{btabular}{lr}

blog & quality\\

what’s new & excellent\\

in theory & poor

\end{btabular}

and without borders as in

\begin{tabular}{ccc}

$a$ & $\rightarrow$ & $b$\\

$\downarrow$ & & $\uparrow$\\

$c$ & $\rightarrow$ & $d$

\end{tabular}

(The tabular environments will be centered in WordPress, but

not in the LaTeX preview.)

And it is possible to include a picture so that the pdf file produced

with pdflatex imports it from a local image file (which has to be

pdf, gif, jpeg, or png) and the WordPress post imports it from a URL.

\image{width = 400}{http://imgs.xkcd.com/comics/donald_knuth.png}{knuth.png}

The {\em image} command used to generate the above image

has three parameter: a size parameter for either the width or the height,

expressed in pixels (if different from the original resolution, the picture

will be scaled), a URL for the location of the image (this will be used

by WordPress) and a local file name (which will used by pdflatex).

It is possible to have numbered and unnumbered sections and subsections.

References to {\em label} commands which are not in the scope of

a numbered equation or a numbered theorem-like environment

will refer to the section number,

such as a reference to Section \ref{sec} below.

HTML does not have good support for itemized list with

descriptors (what one gets in LaTeX using the {\em itemize} environment

with optional parameters in square brackets after the {\em item} commands).

We can only offer the following rather ugly rendering:

\begin{itemize}

\item [Case a.] Description of case a

\item [Case b.] Description of case b

\end{itemize}

\section*{Examples of Sections}

\subsection*{And Subsections}

\section{A section}

\label{sec}

\subsection{And a subsection}

\section{Changing the style}

The file latex2wpstyle.py contains several definitions that determine

the appearance of the WordPress translation. It should be self-explanatory

to change the way sections, subsections, proofs and theorem-like

environments are typeset, and to change the numbering scheme

for theorem-like environments.

The variable $M$ in latex2wpstyle.py contains a list of pairs of strings.

For every pair, every occurrence of the first string in the document is

replaced by an occurrence of the second before proceeding to the

conversion from LaTeX to WordPress. If you want to use simple macros

(which do not involve parameter-passing) then edit $M$ to add support

for your own LaTeX macros. (You will have to define the macros in

macrosblog.tex as well, otherwise you will not be able to compile

your LaTeX file and preview it.)

Some macros are already defined. For example, backslash-E produces

an expectation symbol:

\[ \E_{x \in X} f(x) := \sum_{x\in X} \P [x] \cdot f(x) \]

Some more macros (see the LaTeX source)

\[ \B, \R , \C, \Z, \N , \Q, \eps \]

\end{document}

Pingback: LaTeX and WordPress.com | Thiago G. Martins

To answer the posts by Vivek and hugo, I think all you need to do is to replace the division operator “/” on line 140 and 153 with the integer division operator “//”. To understand why, see

http://www.daniweb.com/software-development/python/threads/450103/float-object-cannot-be-interpreted-as-an-integer

Thank you, Luca, for writing this program.

thanks for writing this program!

however, I am getting a similar error as Vivek above.

I tried with the example.tex given in the zip.

Traceback (most recent call last):

File “c:\python31\l2wp\latex2wp.py”, line 657, in

s=extractbody(s)

File “c:\python31\l2wp\latex2wp.py”, line 140, in extractbody

for i in range(1,(len(L)+1)/2) :

TypeError: ‘float’ object cannot be interpreted as an integer

Pingback: De Latex a WordPress | Notas breves de Matemáticas

I am getting the same error as spencer. It says invalid syntax. May someone help? Thanks a lot!

This is cool…. (y)