
LaTeX Blogging with Emacs
January 21, 2010As 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.
That is freaking awesome.
If I can write everything in LaTeX, I’ll have no excuse not to keep up with my blog.
Please do post some screenshots and more details about all this. It sounds wonderful. WordPress.com is OK in my book but some of the interfacing, including the post editor, appears to have been written by monkeys. What you’re describing sounds orders of magnitude more clean and simple.
I haven’t used Emacs since college (I’m using TextMate on a Macbook Pro) but I’d be willing to pick it up again if it’ll make blogging simpler.
Done!
I’ve heard TextMate is quite good, and as long as it can execute an external command, I’m sure you could have a setup like mine. The scripts are written in python, so the editor doesn’t need to be emacs to make this work.
How did you figure out how to use the python library to access WordPress directly? There doesn’t seem to be much documentation. Or maybe I’m just stupid.
Yeah, the documentation is sparse. The main thing is to start with the example on the page I linked to. You just need to change a couple of the fields, so I think your url should be “http://mathaftermath.wordpress.com/xmlrpc.php” Then change the username and password too.
I think that was enough to get it running for me.
[...] of semester By christopherdrup Wow. I just read Eric’s post over at Curious Reasoning, and I have to say that I am all fired up to start blogging directly in LaTeX. Plus, I’m [...]
[...] that I have found a much more convenient way to post the examples. Starting with this post at his Curious Reasoning blog, Eric Finster has shown two ways of posting code and images to WordPress. For example, for the [...]
[...] that I have found a much more convenient way to post the examples. Starting with this post at his Curious Reasoning blog, Eric Finster explained a way of posting code and images to WordPress. For example, for the [...]
Emacs also has a nice plugin that lets you preview LaTeX output (without actually compiling a PDF or DVI).