LaTeX Blogging with EmacsJanuary 21, 2010
As a mathematician, I am constantly using Latex to write mathematics. I use it for my own notes and ideas, for writing papers, doing homework, making quizzes and handouts for my class, just about everything. In fact, since I’ve become reasonably profficient, I find little use for any other word processors. The separation that Latex provides between the contents of a document and its format is extremely useful, and now that I’m used to it, I find that most WYSIWYG editors make it more difficult to get a document formatted like you want it, not less. Besides, writing most of my documents in Latex means I get to spend plenty of time with one of my favorite pieces of software, GNU Emacs.
Seriously. It’s the best.
For a long time I’ve had a really comfortable setup in Emacs where I can just open a new document, insert a standard header for notes, and begin writing. There’s essentially no setup time, and I get straight to the point where I can start doing math. I don’t even really need a pen and paper now. I can do most of my thinking at the keyboard, and that way have everything archived and organized. This is much superior the the mountain of notebook paper from years past which threatens to consume my room as we speak.
But it had long been in the back of my mind that really these notes form something like my mathematical diary, and that if I were to spend just a bit more time explaining the things I was doing, they would form the basis for a blog which covers my work. The only thing left was to sort of streamline the process of cleaning things up and posting them online. So let me describe how I can do that now.
There’s a nice little python script called latex2wp.py which you can read about here. It takes your Latex document and outputs html which can be cut and pasted into WordPress. But actually, you can do better if you use this. It’s a little python library for accessing WordPress directly. So I just wrote a little bit of code to connect the two: it first runs latex2wp and the automatically uploads the result. I bound that to one of my Emacs commands, and Voila!.
The upshot is that my blog posts are written in actual Latex on my computer locally, where I can edit, preview, and use all my custom macros. Then when I finish, I just run my script and the result appears on my blog. That’s how this entry was written.
If I get around to it, I might post some screenshots and explain some of the other Emacs customizations which make my life easier.