Converting to Word with citations and equations via pandoc

For the most part, I write in Google Docs; process citations with Paperpile; and then export to Word.

But, if I have a document with a lot of mathematics, I don’t like using Google Docs’ feeble equation editor. Instead, I put the math in LaTeX between dollar signs; download to Word; use pandoc to convert to Markdown; unescape the dollar signs and other escaped characters in the Markdown file; and then process the md file to Word.

What about files with Paperpile citations as well? Here is my workflow - a bit complicated, but it works perfectly:

  1. Using the Paperpile add-on, Export the document with BibTeX citation codes; and download that new document as a Word file

  2. From the same Export panel, export the references as BibTeX (as references.bib by default)

  3. Process the Word file to Markdown using pandoc (e.g., pandoc -o file.md file.docx

  4. Open the markdown file (I use emacs). Replace each \\cite{ with [@ and the matching } with ]

  5. Clean up the math, removing the backslash escapes (both these steps can be done easily in Emacs with regular expressions)

  6. Process again with pandoc: pandoc -C --bibliography=references.bib -o final.docx file.md

In the final step, you can convert to any format you want, including LaTeX, instead of docx.

I thought this might be useful to other Paperpile users who, like me, use Google Docs, but have to handle complicated mathematics as well as references.

1 Like

really useful, thanks a lot.
This is exactly the flow I use. However, I 'm not doing the latex equations escape after converting to markdown. I get lots of \$. How do you escape all of these??
thanks in advance.