5

I have to generate a Microsoft Word document (many, but all of them using the same template). I would like to generate it in the same way in which I generate PDF documents from LaTeX sources, i.e. using a WYSIWYM editor, macros, Git, etc. In fact, if could use a more powerful programming language, that would be better.

In particular I need:

  1. Compile to Word files.
  2. Use cross references (ideally with something like cleveref).
  3. Easily add bibliography (ideally with BibTeX, but I could implement that myself).
  4. Ideally also: procedurally define diagrams with something like Tikz/PGF (but I could embed Tikz/PGF, generate an image calling some external program and then use it).

I thought initially of XSL-FO, but it seems to be at a different level of abstraction when compared with LaTeX. A painful one. I may be missing something, but I wasn't able to find a way to reasonably write a document by using it directly or some related tools. As far as I could see, it seems to be closer to Postscript than to LaTeX (lots of explicit absolute positioning). Most tags in WordML are just one letter tags, not very human-friendly, and then I am uncertain about how to generate the actual DOC or DOCX from that XML.

Pandoc (and similar tools) seems to be limited to a basic set of features (as the ones available for Markdown), so that it can cover a wide range of formats, but at the cost of missing many features in each of them. Basically the output is garbled.

Similarly for the case of latex2rtf. The output is missing so much of the input that it is rather pointless trying to use it.

An interesting case is pdf2htmlEx. It generates a nearly perfect HTML output from the PDF, but Word cannot really open that HTML file properly. This means that it may be possible to generate a Word file from a PDF using some similar tool, but judging by the output of pdf2htmlEx, editing that file may prove as a challenge.

So the questions are: Am I missing something? Do you know about any sane tool that satisfies the three (ideally four) requirements that I wrote? Which is the best tool workaround to generate DOC or DOCX from plain text?

1
  • I use to write such a generator (without cross references though) using LibreOffice. LibreOffice's OpenDocument format is pleasant to work with, style and content are properly separated. LibreOffice includes a command-line tool to convert documents to various formats, including Word format. It could be part of a solution.
    – Nicolas Raoul
    Apr 25, 2016 at 6:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.