TL;DR: If you want to customize your tables and you don’t want to start with Pandoc’s default
reference.docxtemplate, you need to create your own new table style, name itTable, and modify that style to do whatever you want tables to do.
I’m helping automate a documentation process at work, and the last step involves converting a Markdown file to .docx. The team we’re helping sent over a reference file with all their custom “styles” (in quotes here because none of the formatting they want to use is a style in the Word sense of the word).
We’re using this reference file as our template to apply custom styling when we run the conversion. We need to associate all the custom formatting in this doc with the Word styles Pandoc knows about so that Pandoc can apply those styles correctly. This was going fine until I couldn’t get Pandoc to apply our custom table styles.
It turns out that when you pass a reference.docx file to Pandoc, it applies any styles from the table style called Table to the tables in your converted document. I tripped on this because there’s no default table style named Table in Word, and the first Stack Overflow answer I came across suggested the solution is to edit the raw XML in your converted document.
I should note here that the Pandoc user guide does identify the table style from reference.docx as “Table”, but I don’t think that would have been enough for me to connect the dots. Also noteworthy is that when I google this on my personal computer, Google’s AI summary immediately tells me that I should create a new table style named Table. But Google’s AI summary is disabled on my work device, and I’ve had plenty of bad experiences using LLMs to troubleshoot Pandoc edge cases, so I thought I was making the smart choice by avoiding using the LLMs endorsed by our enterprise for this search.
I went about this the hard way, of course. Because it didn’t occur to me that I could just create a new table style called Table (or even to try this approach), I generated a new version of the reference.docx file, used Style Organizer to export that style to my own reference file, and went from there. I only learned you can indeed create your own new table style and even give it a custom, unique name (like, well, Table) until I started writing up this post to help other lost souls like myself and it occurred to me that I should probably just double check real quick that my workaround is indeed the only way to accomplish this task. Woe.