Search code examples
markdowndocxpandoc

Why am I unable to use my custom-reference.docx when converting md to docx with Pandoc?


I'm trying to convert markdown to a docx file with Pandoc using a custom reference doc. I created a reference doc according to the Pandoc manual and placed it in my .pandoc folder. Here's a mwe of the error I'm getting.

$ cat test.md
---
title: Minimal Working Example
author: test
---

## This is a test

I am trying to get a custom reference doc to work, but I'm having trouble.
Here is a minimal working example.
$ pandoc --version
pandoc 2.17.1.1
Compiled with pandoc-types 1.22.2.1, texmath 0.12.4, skylighting 0.12.3.1,
citeproc 0.6.0.1, ipynb 0.2
User data directory: /home/jonathan/.pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
$ ls /home/jonathan/.pandoc
custom-reference.docx
$ pandoc --reference-doc=custom-reference -o test.docx test.md
pandoc: custom-reference: openBinaryFile: does not exist (No such file or directory)

I've also tried running the command with --reference-doc=custom-reference.docx and even --reference-doc=/home/jonathan/.pandoc/custom-reference with no luck. I cannot for the life of me figure out what I'm doing wrong.


Solution

  • It looks as though you've conflated a couple of bits in the Pandoc manual.

    It advises that if it can't find the reference file, that it will then look in .pandoc for reference.docx, not that this is where you should put your custom-reference.docx

    If you place custom-reference.docx in the same folder you're running Pandoc in (wherever your markdown file is that you're converting), it should then pick it up.