[Tex/LaTex] TeX to DOCX via Pandoc with ACM template

acmmswordpandoc

For unfortunate reasons, I need to convert a latex document to word. The document was created using an ACM template (available here); I've read bread thing about pandoc and I was hoping to use it to handle the conversion.

I quickly fired up my terminal, installed pandoc via homebrew (OS X user here) and downloaded the template (see link above) to test the conversion process. However, despite many trials and extensive googling, I still can't figure out how to tell pandoc to use the provided template (provided as .cls file) to render the document correctly.

I've tried to run:

pandoc -f latex -t docx  sig-alternate.tex --biblatex --bibliography sigproc.bib -o sig-alternate.docx

here's a side by side comparison between the .docx generated by pandoc and the pdf generated via MacTeX:

comparison-pdf-doc

I'm clearly missing some step(s) here. Can someone enlighten me? Thanks!

Best Answer

Pandoc cannot use a template provided as a *.csl file to style its DOCX output.

If you want to get Pandoc using a specific set of styles, you need to create (or grab) another DOCX file containing these styles. Note, that the style names do need to conform to the standard names in the first place. (In the past I've succeeded to let it use non-standard style names in cases where one of the standard styles is set up to enforce another style, f.e. in "next paragraph"..).

The commandline option to add is --reference-docx=...

Also, be sure to use the very latest version of Pandoc. Its support for DOCX is very new, and evolving still very rapidly.

The command for Pandoc would be:

  pandoc sig-alternate.tex                \
       --from=latex                       \
       --to=docx                          \
       --biblatex                         \
       --bibliography sigproc.bib         \
       --output=sig-alternate.docx        \
       --reference-docx=my-reference.docx

One other hint: if the direct conversion is not satisfying you (there may be spots where the thing doesn't look right), you should proceed like this:

  1. Convert the LaTeX to Markdown first (also with the help of Pandoc).
  2. Edit the resulting Markdown (consult man pandoc_markdown and man pandoc to see what special options and extensions Pandoc supports).
  3. Convert the improved Markdown sources to DOCX (don't forget to use --reference-docx=...)
Related Question