# Help needed with basic steps to compile through Pandoc into .docx and .odt

**URL:** <https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469>\
**Category:** Scrivener\
**Tags:** support, compile, markup, metadata\
**Created:** [November 29, 2025, 9:53am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469 "2025-11-29T09:53:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tqctc](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/tqctc/32/41133_2.png) [@tqctc](https://forum.literatureandlatte.com/u/tqctc)\
**Post date:** [November 29, 2025, 9:53am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/1 "2025-11-29T09:53:53Z")

</div>

I am trying to understand how to make full use of compiling for Pandoc. I must admit that the learning curve is very steep for me. I have tried tools and tutorials that I find challenging to understand. I probably lack acquaintance with the very first steps. Having not seen a forum thread or a step-by-step guide to help me move forward with what I want to do next, I have decided to ask here. Apologies if the response is already available somewhere else.

So far, I have managed to compile into .docx and .odt using my own Pandoc templates, each with its own styling. Additionally, I can also get floating Zotero citations, which I transform into the desired citation style in Word or LibreOffice. Everything works well [after this issue was solved.](https://forum.literatureandlatte.com/t/pandoc-to-word-postprocessing-issue/152245/8)

Now, my reference.docx or reference.odt templates have a list of styles, created directly in Word and LibreOffice. Compiling into MultiMarkdown and post-processing with Pandoc smoothly attributes many of them to the final document: Main title, Author, Header 1, Header 2, Footnotes, etc. No issues here—it works out of the box.

For other styles, such as Abstract, Subtitle, and those created by me (Affiliation, for instance), it seems I need to configure Scrivener to pass the information to Pandoc and have it properly attributed to the respective styles in the final document. I have no clue about how to proceed. I guess it has to do with metadata (the information that appears at the top of the .md file). But how to introduce metadata for, say, the Abstract and the Affiliation fields? Using the metadata options in the Compile Overview? I get a line for Abstract, another for Affiliation, but the content does not appear in the final document. Inserting them in a front-matter section? Using custom categories such as \<$author\> and then writing the content somewhere? I feel completely lost. I would really appreciate some help. Thanks!

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [November 29, 2025, 7:04pm UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/2 "2025-11-29T19:04:33Z")

</div>

Pardon my confusion on the thing you’re trying to do, but you are using the word styles to describe what sounds to me like Pandoc metadata, what would go within the `---` markers in the document? You wouldn’t ordinarily use styles for that in Scrivener, that would be how you mark up text in the editor.

> Using the metadata options in the Compile Overview?

Precisely so, I don’t know why that isn’t working for you. Perhaps a demonstration will help. There are two different approaches I take, depending upon the project, and this sample demonstrates both.

[metadata\_test.zip](https://forum.literatureandlatte.com/uploads/short-url/8FRMLFXf7PBPVniNUqaQnzvR27M.zip) (72.6 KB)

1. First compile it using the given settings. To be clear, if you visit the Metadata tab in compile overview you will find I have cleared it entirely. Normally you would of course want to put your project-specific metadata, like the Title and Author, in here. Instead I’ve moved everything over to the compile Format’s own Metadata tab, so that you can very easily switch between the two methods without have to delete a bunch of stuff from the compile overview Metadata tab.

2. Next, select the “Binder Metadata” compile Format, and note how this will select the “Full Metadata” document for the **Add front matter** feature. You don’t have to use that, again this just makes the demonstration simpler, so you can click between the two Formats to get an idea of the different ways to do this.

Once that is done, check out the “Full Metadata” item in the binder. Of note, I _am_ using a style here, but to be perfectly clear this is _cosmetic only_. I just use a style like this for metadata blocks so that the values all line up neatly and there is a little space between rows. It performs no function in the compile settings.

Which to use? It’s entirely up to you. I often just use a text section in the binder because that’s easier to me than messing around with the GUI. I can copy and paste it from an existing file, and that sort of stuff.

---

<div class="post-metadata">

**Author:** ![tqctc](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/tqctc/32/41133_2.png) [@tqctc](https://forum.literatureandlatte.com/u/tqctc)\
**Post date:** [November 30, 2025, 1:45am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/3 "2025-11-30T01:45:12Z")

</div>

I start to understand how it works. Using the “Compile Settings” Format works well enough, although I prefer the second option.

> [@AmberV](#):
>
> Next, select the “Binder Metadata” compile Format, and note how this will select the “Full Metadata” document for the **Add front matter** feature.

It worked, but I had to change the section type of the “Full metadata” document to match the As-If section layout; otherwise, the result would appear without the `---` markers:

```nohighlight
Full metadata
title:	Metadata
subtitle:	A Pandoc YAML Test
author:	AmberV
date:	30 November, 2025
abstract:	This project demonstrates a few different techniques for applying Pandoc/MultiMarkdown metadata to a document upon compiling.
affiliation:	Literature & Latte
copyright:	Public domain. Please feel free to use these examples in your own work, or share them with others.
Test Section
Main content begins.

```

However, I’ve noticed a difference between the output when using the Metadata in the compiler settings:

```nohighlight
---
title: Metadata
subtitle: A Pandoc YAML Test
author: AmberV
date: 30 November, 2025
abstract: This project demonstrates a few different techniques for applying Pandoc/MultiMarkdown metadata to a document upon compiling.
affiliation: Literature & Latte
copyright: Public domain. Please feel free to use these examples in your own work, or share them with others.
---

# Test Section #
Main content begins.

```

And when using the second approach:

```nohighlight
---
title:	Metadata
subtitle:	A Pandoc YAML Test
author:	AmberV
date:	30 November, 2025
abstract:	This project demonstrates a few different techniques for applying Pandoc/MultiMarkdown metadata to a document upon compiling.
affiliation:	Literature & Latte
copyright:	Public domain. Please feel free to use these examples in your own work, or share them with others.
---

# Test Section #
Main content begins.

```

In the second case, spacings of different lengths have been added before the metadata content. I am not sure if this is an issue or if I can ignore it.

Now, I want to postprocess it with Pandoc to .odt and .docx. I have ensured that my reference templates include the “Abstract” and “Affiliation” styles (with those exact names). The output .odt document, however, only shows “title”, “subtitle”, “author”, “date”, and the first header, formatted in their respective styles; “abstract” and “affiliation” have not made it into the document. As for .docs, the “abstract” metadata content appears formatted as “Abstract” in the resulting document, but not “affiliation”. How do I move next?

---

<div class="post-metadata">

**Author:** ![nontroppo](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/nontroppo/32/15746_2.png) [@nontroppo](https://forum.literatureandlatte.com/u/nontroppo)\
**Post date:** [December 1, 2025, 9:12am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/4 "2025-12-01T09:12:46Z")

</div>

The next step is that you must create a template: [https://pandoc.org/MANUAL.html#templates](https://pandoc.org/MANUAL.html#templates) for Pandoc that uses the metadata and produces content from it. For text based outputs like TeX/HTML/Typst this has always been easy as the templates are easy to edit and implement. My scrivomatic workfow demonstrates this, with affiliations, corresponding and equal authors etc. for HTML and PDF directly:

 ![Screenshot_2025-12-01-16-51-42](https://forum.literatureandlatte.com/uploads/default/original/3X/b/0/b05e4088aca90b5b6cca3441075fcab59ac01dac.png)

For DOCX this used to be harder it is a zip bundle format and the reference.docx is only for styles, not content. **BUT** good news as recently Pandoc supports templating for DOCX as it did for other formats. The default template for ODT:

> <https://github.com/jgm/pandoc-templates/blob/master/default.opendocument>

and for DOCX:

> <https://github.com/jgm/pandoc-templates/blob/master/default.openxml>

You can also copy these from pandoc locally, e.g.

`pandoc -D openxml > /Users/<YOU>/.local/share/pandoc/templates/custom.openxml`

The `$if(variable)$` syntax allows you to inject in content if that metadata field exists. Taking DOCX as an example you create your template (see above), and edit it to add the fields you want, and move the existing fields around. So you could add in affiliation (reusing the author styling) from your metadata like:

```xml
$if(affiliation)$
    <w:p>
      <w:pPr>
        <w:pStyle w:val="$author-style-id$" />
      </w:pPr>
      $affiliation$
    </w:p>
$endif$

```

Then when you run pandoc you use this template so `pandoc --output test.docx --template custom.openxml test.md` – pandoc looks in `~/.local/share/templates` by default or you can store it somewhere else and use an absolute path. This system came after I developed the scrivomatic template so my example workflow doesn’t demonstrate this yet, it is on my long todo list.

`$if$` deals with single items, but if you have a list of items (more than one affiliation), then `$for$` can loop through each item in the metadata list and generate content for you. As you inject raw openxml / opendoc syntax you can do some low level control of word/libreoffice…

---

<div class="post-metadata">

**Author:** ![nontroppo](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/nontroppo/32/15746_2.png) [@nontroppo](https://forum.literatureandlatte.com/u/nontroppo)\
**Post date:** [December 1, 2025, 9:27am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/5 "2025-12-01T09:27:06Z")

</div>

There are a few other tricks involving pandoc filters. For example there is an abstract filter:

> <https://github.com/iandol/dotpandoc/blob/master/filters/abstract-section.lua>

This looks for a section in the main text with a heading “Abstract” and move it into the metadata for compile (thus taking advantage of your template and its styles). At least in my field abstracts are critical and it is nicer to edit in as a Scrivener document rather than yaml metadata…

Filters can do a bunch of other cool things, but, well, one step at a time 😁

---

<div class="post-metadata">

**Author:** ![tqctc](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/tqctc/32/41133_2.png) [@tqctc](https://forum.literatureandlatte.com/u/tqctc)\
**Post date:** [December 2, 2025, 1:23am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/6 "2025-12-02T01:23:23Z")

</div>

Thanks @nontroppo for your detailed explanation! I am going step by step, trying to understand what I am doing each time.

> [@nontroppo](#):
>
> The next step is that you must create a template: [Pandoc - Pandoc User’s Guide](https://pandoc.org/MANUAL.html#templates) for Pandoc that uses the metadata and produces content from it.

I have several different reference documents for various uses, for instance, reference.doc journal1.docx, journal2.odt, handout.odt, etc., as well as the two defaults reference.docx and reference.odt, all of them located in my Pandoc user data directory.

After unzipping the .odt and .docx reference documents, I can edit the content.xml file (I understand it is content.xml for .odt and document.xml for Word, but correct me if I am wrong). But should I do that for each different template? Or can I edit the default pandoc template so that it automatically recognizes the metadata for every new reference document?

---

<div class="post-metadata">

**Author:** ![nontroppo](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/nontroppo/32/15746_2.png) [@nontroppo](https://forum.literatureandlatte.com/u/nontroppo)\
**Post date:** [December 2, 2025, 4:06am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/7 "2025-12-02T04:06:58Z")

</div>

> [@tqctc](#):
>
> After unzipping the .odt and .docx reference documents

_Reference docs_ and _Templates_ are _ **two different things** _:

1. Templates are used to modify document content with metadata. _ **Content!** _
2. Reference docs are exclusive to DOCX and ODT and can only be used to modify styles and some other packaging details, they cannot modify the content itself. _ **Aesthetics!** _

**Do not change your reference docs** or try to merge these: you add a new template file and you call both the reference-doc and templates when running pandoc like:

```nohighlight
pandoc --reference-doc custom.docx --template custom.openxml ...

```

You create custom templates\[1\] based on the default one just as you have done for your reference-docs. `custom.openxml` and `custom.opendocument` can be stored in your pandoc data directory or elsewhere if you prefer.

* * *

1. you could make new default templates, but if there is a bug it is hard to fix, so I recommend not replacing default templates unless you are a pandoc pro

---

<div class="post-metadata">

**Author:** ![tqctc](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/tqctc/32/41133_2.png) [@tqctc](https://forum.literatureandlatte.com/u/tqctc)\
**Post date:** [December 4, 2025, 11:01am UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/8 "2025-12-04T11:01:15Z")

</div>

> [@nontroppo](#):
>
> - Templates are used to modify document content with metadata. _ **Content!** _
> - Reference docs are exclusive to DOCX and ODT and can only be used to modify styles and some other packaging details; they cannot modify the content itself. _ **Aesthetics!** _

I understand this now. I obtained Pandoc’s ODT template with this `pandoc -D odt > template.xml`. I edited it to add Affiliation and Abstract:

```nohighlight
$endfor$
$if(affiliation)$
<text:p text:style-name="Affiliation">$affiliation$</text:p>
$endif$
$if(date)$
<text:p text:style-name="Date">$date$</text:p>
$endif$
$if(abstract)$
<text:p text:style-name="Abstract">$abstract$</text:p>
$endif$

```

Now I call both the reference document and the template, alongside all the other stuff:

```nohighlight
--verbose -s -f markdown+smart --reference-doc="C:\Users\xxx\AppData\Roaming\pandoc\handout-en.odt" --template=handout-odt-en.xml --lua-filter=zotero.lua --output <$outputname>.odt

```

And both the Affiliation and the Abstract content appear with their respective styles. It is working, thanks!

I have a question. `--template=xxx.xml` works without providing an absolute path. How about `--reference-doc`? Is there a place I should store it to avoid having to use an absolute path?

> [@nontroppo](#):
>
> There are a few other tricks involving pandoc filters. For example, there is an abstract filter:

I will definitely try this later; abstracts are indeed an essential piece of text in their own right.

* * *

So after a lot of trial and error, and with a strong feeling that the learning curve is too steep, I have managed to understand how it works and make it work (so far). Would it not be meaningful to have a pinned wiki thread in the forum that explains, step by step, the basic usage _and concepts_ of Pandoc (such as _reference_ and _template_) for Scrivener users?

---

<div class="post-metadata">

**Author:** ![rms](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rms](https://forum.literatureandlatte.com/u/rms)\
**Post date:** [December 4, 2025, 12:35pm UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/9 "2025-12-04T12:35:30Z")

</div>

> [@tqctc](#):
>
> Would it not be meaningful to have a pinned wiki thread in the forum that explains, step by step, the basic usage _and concepts_ of Pandoc (such as _reference_ and _template_) for Scrivener users?

Just curious … how is Chapter 21 of the _ **Scrivener Manual** _ not scratching that itch at least initially? Innocently asking as I don’t (yet) use Pandoc, but I’d start there supplementing with existing _ **Pandoc User’s Guide** _ by John MacFarlane.

---

<div class="post-metadata">

**Author:** ![tqctc](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/tqctc/32/41133_2.png) [@tqctc](https://forum.literatureandlatte.com/u/tqctc)\
**Post date:** [December 4, 2025, 1:26pm UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/10 "2025-12-04T13:26:47Z")

</div>

> [@rms](#):
>
> how is Chapter 21 of the _ **Scrivener Manual** _ not scratching that itch at least initially? Innocently asking as I don’t (yet) use Pandoc, but I’d start there supplementing with existing _ **Pandoc User’s Guide** _ by John MacFarlane.

I tried! Before posting here, I read chapters 21.6 and 21.7 a couple of times. But I only understood what I had to do (and what those chapter where dealing with) after opening @AmberV’s [sample project](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/2) and seeing how it works.

As for _Pandoc User’s Guide_, the first sentence in “Using Pandoc” (the first section of the Guide after the “Description”) is: " If no _input-files_ are specified, input is read from _stdin_. Output goes to _stdout_ by default. For output to a file, use the [`-o`](https://pandoc.org/MANUAL.html#option--output)/[`--output`](https://pandoc.org/MANUAL.html#option--output) option:"

It does not explain first what _stdin_ and _stdout_ are. I am not saying it does not explain that elsewhere in the manual. But that is not a step-by-step guide _for me_. I felt immediately lost.

> [@tqctc](#):
>
> Would it not be meaningful to have a pinned wiki thread in the forum that explains, step by step, the basic usage _and concepts_ of Pandoc (such as _reference_ and _template_) for Scrivener users?

What I meant is something [like this](https://forum.literatureandlatte.com/t/using-scrivener-with-reference-software-wiki/132295/4), containing for instance the sample template to test. I managed to use Scrivener with Zotero without fully understanding what Better BibText or a lua filter are. I did not need to read their manual (although I did indeed refer to Scrivener’s manual to learn how to add Pandoc postprocessing in the Compile menu). Or Scrivener’s tutorial vs. reading the manual as a first step.

---

<div class="post-metadata">

**Author:** ![rms](https://forum.literatureandlatte.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rms](https://forum.literatureandlatte.com/u/rms)\
**Post date:** [December 4, 2025, 1:31pm UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/11 "2025-12-04T13:31:16Z")

</div>

Good explanation of what that person(s) who writes this for you can explain to supplement the already-written resources. Who that will be, I don’t know. Thanks.

---

<div class="post-metadata">

**Author:** ![AmberV](https://forum.literatureandlatte.com/user_avatar/forum.literatureandlatte.com/amberv/32/13021_2.png) [@AmberV](https://forum.literatureandlatte.com/u/AmberV)\
**Post date:** [December 4, 2025, 1:32pm UTC](https://forum.literatureandlatte.com/t/help-needed-with-basic-steps-to-compile-through-pandoc-into-docx-and-odt/152469/12 "2025-12-04T13:32:48Z")

</div>

Yes, to be fair, the chapter in our user manual does not in any way dip into documenting Pandoc or MultiMarkdown. I don’t feel it is our place to be doing so, and that would just add a lot of overhead for me, having to edit these areas whenever they change. Sorry if I misunderstood your suggestion about a Pandoc how-to wiki page on the forum here, but that is how I took it.

> It does not explain first what _stdin_ and _stdout_ are. I am not saying it does not explain that elsewhere in the manual. But that is not a step-by-step guide _for me_ . I felt immediately lost.

Exactly, Pandoc’s documentation is fantastic, but it is definitely aimed at a segment of people that probably feel more comfortable with the concept of using a computer with a shell window or two open.

I’m surprised there isn’t anything out there that is written more as a general guide for writers using Pandoc. It may be worth searching a bit on that, without Scrivener in the search term to loosen it up a bit. After all Scrivener’s involvement is pretty outside of all of these matters. The closest you get to them is in the Processing pane.
