[Tex/LaTex] How to convert a Google docs document to LaTeX


I am working in a team with people who didn't know LaTeX, and while I would have loved to get them into it through shareLaTeX or a similar service, we don't have the time for this. As a result, we are working on Google Docs. But while the WYSIWYG is really helpful for them, I am very frustrated with the limitations of the interface and the tediousness of making it look good¹ and I would like to get it as a LaTeX document, essentially keeping the structure (Keeping paragraphs, turning headings into \sections and so on, maybe even page breaks!) and the basic style (bold, italics…)

So: is there a way to convert a Google docs document to a LaTeX file while retaining as much of its structure as possible?

1. And don't get me started on the bibliography. Ugh.

Best Answer

I have found a way through html export

  1. Download the document as html
  2. Use Pandoc to convert the html to LaTeX

It is not perfect but better than my old Markdown solution (see below) and preserves most of the original document. It even keeps images!

An inferior solution that I'll leave here because the export from/to Markdown could still be useful for future readers:

  1. Use Renato Mangini's gdoc2md script to get a Markdown export of your doc. The install instructions are a bit outdated, but it's nothing to be afraid of.
  2. Use Lunamark or Pandoc to get a LaTeX document from the resulting Markdown. You can even make it standalone (or even export to something else than LaTeX)

Now obviously it is not a very polished process and the resulting LaTeX will need some tweaking to get things right, but at least it keeps the \section structure, most of the basic formatting (not fancy things like colours, though), the lists and all the Markdown I did originally use in the Google doc to mark the places where I wanted to put fancy formatting later (e.g. > for quotes).