Hacker News new | ask | show | jobs
by wowczarek 9 days ago
To me, Pandoc is "never have to touch Word again", in other _words_, salvation.

Sadly, the .docx templates aren't enough - they have the styling, but for those forced to produce a .docx output as a necessity for "corporate" consumption - you will find it that it's not quite straightforward to insert a title page, and out of the reference docx file, only the styles are used, not the content. You can define headers and footers in the reference file, but not more than that.

As of 3.2.1, Pandoc supports OpenXML template files for its docx writer as well as pre and post body insertion: --template, --include-before-body and --include-after-body, but if you prefer to define your title page in Word, or haven't gotten your head around doing an OpenXML thing like me, I found this Windows tool:

https://github.com/jamessantiago/DocxMerge

You can define your title page in one docx file and then merge it with Pandoc's output. But since styles from both get merged, it's best to start your title page with a copy of your reference and/or delete as many styles as possible from your title page so you don't have to make changes to both.

There are also some other quirks like fitting tables to contents properly in docx - a workaround is a PowerShell script (shock, horror), that opens the file, iterates over tables, sets autofit and saves the document.

Doing "Werd" right: edit markdown, type "make". -> docx, pdf. The world is a good place sometimes.