0

I am working with knitr and rmarkdown, and I want to customize the resulting Word document. It works very nicely, except for one thing. I can specify the Title and Author in the YAML part of the markdown document, and I can later recover them as fields in Word, and in particular, I can add them to the header and/or footer.

However, I haven't been able to do the same thing with the Date fields. It gets printed in the body of the resulting document, but the CreateDate (or Date) field always contain the time pandoc generated the docx file, which is not useful to me.

Is there any way to recover this information in Word ?

Here is a short markdown file with 3 metadata fields:

---
title: "Test document"
author: "Test author"
date: "2023/01/01"
---

Test document.

After using pandoc test.md --to docx --output test.docx, I obtain a docx file, in which I can add the Title and Author fields in the footer, and it works. But the CreateDate file is always the date at which I ran pandoc.

I looked into the docx Zip file; custom.xml contains my date ok, but core.xml contains only the date when Pandoc was ran (both files contain my title and author fields), and I don't see a way to get the value from custom.xml into the document.

A past question seemed to indicate that the poster managed to set CreateDate to what he wanted, but I can not reproduce it (and maybe he was happy enough with the pandoc date).

0 Answers0