Category Archives: LaTeX

Exporting Deviance Tables to (ugh) Word

I do my absolute best to minimize the amount of time Word is open on my computer desktop.  Alas, when one collaborates widely, particularly with non-technical people, it is a necessary evil.

In these collaborations, I am typically doing either statistical or modeling work (or both). This often means that I am generating objects in R, such as Analysis of Deviance Tables, that I would like to put into the working document.  This can be an enormous hassle, particularly when your data set is repeatedly updated and the table changes ever so slightly with each iteration of the paper.  It's not such a big deal for small tables, but when there are lots of covariates on the model it is a maddening, time-consuming, hypertensogenic experience.

This has been a particularly acute problem of late as we wind down to the final draft of two big papers with substantial data analysis (and fair sized analysis of deviance tables). I am not joking when I say a solution came to me in a fevered dream.  I'm surprised it hadn't occurred to me before, given past posts on related topics, but what can I say? 

So, here is my basic Kekulé-esque idea: Output the table to a dummy LaTeX document using xtable. After texing, convert the file using LaTeX2rtf.  It's then a simple matter of opening the rtf file in Word.  Copy and paste and voilà tout!  Seems like it works pretty well.  Can anybody think of a less Byzantine way to do this?

More On Converting LaTeX

This is turning into a series, now isn't it? Yesterday, I wrote a post on using tex2word to convert \LaTeX documents to .doc format.  This works well but carries with it the major disadvantage that you need to run it using windows.  In my copious spare time, I thought I would explore some of the other options listed on the PLoS ONE LaTeX page.

An intriguing alternative to tex2word is LaTeX2rtf, a freeware utility that runs on a variety of platforms (including all UNIX-like operating systems).  I downloaded it, built it and ran it with few problems in between my dozen or so events today.  Considering how little time I had to devote to it and how distracted I was, it worked remarkably well.  I tested the converter out on a pretty equation-loaded document. The equations don't look perfect, but they're passable.  One major advantage that LaTeX2rtf has over tex2word is the preservation of cross-references and (key) the bibliography.  I clearly need to play around more, but my sense is that LaTeX2rtf is the tool to use if you have a document that doesn't have too many complex typeset equations.  When that is the case, the equations rendered by MathType via tex2word will probably look better.  But if you go that route, you need to do extra work to do the bibliography and you lose the cross-references.

I learned from Pete Binfield, editor of PLoS ONE, some terrific news today. PLoS ONE will be accepting LaTeX submissions starting in January. This whole thing of exploring LaTeX converters started with me trying to figure out what I was going to tell some authors of a paper submitted to PLoS ONE.  The submitted manuscript was done in LaTeX and I wanted to have something constructive to say other than "you can't."  Pretty soon, I won't have to worry about that.  Of course, there are plenty of other times when I can't use LaTeX (but want to) and so converters will be useful.  Probably the most common way this comes up is working with co-authors who have no inclination to work with LaTeX (read: most of them).

LaTeX Filters

I recently joined the editorial board of PLoS ONE.  To facilitate rapid turn-around of accepted manuscripts, PLoS ONE has some fairly rigid requirements for the submission of electronic files.  One of the most unfortunate restrictions is that the journal does not accept manuscripts prepared using LaTeX.  This is a shame because PLoS ONE has published some excellent papers in theoretical population biology (Tulja et al. (2007) and Pavard et al. (2007) are two examples that come immediately to mind).  So, what is an author to do when he or she has a manuscript with a lot of typeset material and intends to submit to PLoS ONE?

There are a number of filters that allow one to write a TeX file to some other format (e.g., .doc, .rtf, .html).  Many of these options are enumerated in this ancient web page, apparently last updated in 1999!  One reasonably acceptable solution that I have found is tex2word, a utility that allows you to read a .tex file directly into Word.  All typeset material is converted using MathType.  Don't be too put off by the extremely hokey website. I have found this software to work pretty well.  It gets confused by some custom macros and it can not help with references managed with BibTeX.  There are other little issues such as the inability to convert objects set in mathcal (e.g., \mathcal{R}_0).  By and large, though, it works remarkably well. The big problem for me is that tex2word only works under windows.  I thus have to start up Parallels each time I want to convert a document (not to mention the hassle of maintaining licenses for things like MS Office and MathType on two platforms).  I don't know if it would work under wine, but I'm sure it works with VMware, so it is at least theoretically accessible to Linux users as well.

So, for would-be contributers to PLoS ONE (and other journals that can't handle LaTeX), despair not!  You don't actually have to write technical papers in Word (my rule of thumb is that if there are two typeset objects -- equations, or even parameters or variables referred to in-text -- it's worth writing in LaTeX).  Write it using LaTeX -- say, in emacs (Aquamacs being my favorite instantiation) --  and convert to Word only after you've let the serious software do all the heavy lifting.