TL;DR: If you want to customize your tables and you don’t want to start with Pandoc’s defaults
reference.docxtemplate, you need to create your own new table style, name itTableAnd modify that style to do whatever you want the tables to do.
I’m helping automate the documentation process at work, and the final step involves converting a markdown file to .docx. The team we’re helping sent us a reference file with all of their custom “styles” (here in quotation marks because any formatting they want to use is not a style in the sense of the word).
We are using this reference file as our template to apply custom styles when we run the transformation. We need to associate all custom formatting in this document with Word styles that Pandoc knows about so that Pandoc can apply those styles correctly. This was working fine until I could get Pandoc to apply our custom table styles.
It turns out that when you pass reference.docx file in pandoc, it applies any style from table style Table In the tables of your converted document. I stumbled upon this because it has no default table style name Table In Word, and the first StackOverflow answer I found suggested that the solution is to edit the raw XML in your converted document.
I should note here that the Pandoc user guide identifies the table style as reference.docx As “Table“, but I don’t think that would have been enough for me to connect the dots. It’s also notable 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 TableBut Google’s AI Summary is disabled on my work device, and I’ve had plenty of bad experiences using LLM to troubleshoot Pandoc Edge cases, so I thought I’d make the smart choice by avoiding using our enterprise-supported LLM for this search,
Of course, I went the hard way about this. Because it never occurred to me that I could create a new table style called Table (or even Effort this approach), I created a new version of reference.docx file, used the Style Organizer to export that style to my own reference file, and went from there. I just learned that you can actually create your own new table style and even give it a custom, unique name (like, well, Table) Until I started writing this post to help other lost souls like me and it occurred to me that I should probably quickly double-check that my solution is really the only way to accomplish this task. well damn.
<a href