# Tag Archives: Code

## From LaTeX to .doc for ‘Comparative Politics’

These are largely notes for myself, but maybe others will find them useful.

As per my previous post, I’ve had a paper accepted. The next task is to adjust the manuscript so that it conforms to the journal’s style sheet, and then to get it into a .doc file for submission. I write in LaTeX, so the latter, at least, is non-trivial. After about a day of experimenting, here’s what I came up with.

First, switch to biblatex for handling your citations. It’s really easy and makes life much better! To do this, and go quite far in getting towards the desired document style, add the following code in the preamble of your tex file.

``` \usepackage[style=verbose-trad1, natbib=true, sortcites=true, block=space, isbn=false, url=false, doi=false, dashed=false, dateabbrev=false]{biblatex} \bibliography{path/to/your.bib} ```

Now make sure that (nearly) all of your citations use the `autocite` command, rather than `citep`. (YMMV with `\citet` commands.) One great thing here is that `\autocite` is smart enough to handle punctuation immediately following the command in the right way. So, using `foo bar \autocite{Hicks2012}.` will get rendered as something like either “foo bar (Hicks 2012).” or “foo bar.1”, where the note points to the full reference. You can now toggle between the two by simply setting a different `style=` in the biblatex options (above), and there should be basically no manual editing required.

That gets you quite far towards the correct styles, but not all of the way. Put the following in your tex file’s preamble to tweak various things. In fact, for my own purposes, I have separated this out into a tex file of its own (called ‘comparativepoliticsstyles.tex’), which I include with `\input{path/to/comparativepoliticsstyles.tex`.

``` % % % % From http://tex.stackexchange.com/questions/10682/suppress-in-biblatex/10686#10686.```

``` % Remove 'In:' for all biblatex refs %\renewbibmacro{in:}{} % Remove 'In:' for 'article' biblatex refs \usepackage{biblatex} \renewbibmacro{in:}{% \ifentrytype{article}{}{% \printtext{\bibstring{in}\intitlepunct}}} % % % % From http://tex.stackexchange.com/questions/30704/enclosing-place-publication-in-parentheses. \renewbibmacro*{publisher+location+date}{% \printtext[parens]{% ADDED \printlist{location}% \iflistundef{publisher} {\setunit*{\addcomma\space}} {\setunit*{\addcolon\space}}% \printlist{publisher}% \setunit*{\addcomma\space}% \usebibmacro{date}% }\nopunct% ADDED \newunit} \renewbibmacro*{volume+number+eid}{% \printfield{volume}% % \setunit*{\adddot}% DELETED \setunit*{\addcolon}% ADDED \printfield{number}% \setunit{\addcomma\space}% \printfield{eid}} % % % % From http://tex.stackexchange.com/questions/12806/guidelines-for-customizing-biblatex-styles. \renewcommand*{\newunitpunct}{\addcomma\space} % % % % My own formulation % Suppress titles from opcit refs. \renewbibmacro{cite:opcit}{} ```

```% Make footnotes the same size as the normal text. \renewcommand{\footnotesize}{\normalsize} ```

Almost there. You now need to run `mk4ht oolatex your_file.tex` from the command line. This will generate a .odt file that you can open with OpenOffice, and then convert to a .doc file. You’ll need to use the Tools->Footnotes/Endnotes dialog to position all footnotes at the end of the document, thus making them endnotes. (This is possible on the LaTeX side, but I found that autocites with multiple references came up empty when I did this.)

That should do it, except for the idiosyncracies I’ve probably forgotten.