I'm writing an essay but I'm stuck with a problem. In my little example I've got two Markdown files

  • test1.md: one chapter with two footnotes, [^1] and [^2]
  • test2.md: one chapter with two footnotes, [^1] and [^2]

Converting each file to PDF through pandoc keeps those footnotes the right way. The problem appears when I generate the combined PDF. Then I get the four footnotes ordered from 1 to 4. I use this metadata.yaml:

title: Prueba footnotes
author: javipas
date: 2023-01-11
tags: [documentation, example]
documentclass: book
header-includes: |

And the pandoc command is used the following way:

pandoc -t pdf test1.md test2.md metadata.yaml -s --file-scope --output=test.pdf

But all I get there is the footnotes 1 and 2 (1 and 2 of Chapter 1) at the end of the page where they are shown, and then the footnotes 3 and 4 (1 and 2 of Chapter 2) at the end of the page where they are shown in Chapter 2.

What I want is the footnotes to restart on each chapter, so those 3 and 4 should be again a 1 and a 2. I saw on SuperUser that using the --file-scope flag could help, but it doesn't (or I don't see how). I've seen that there are answers to this if you write the document with a LaTeX editor, but that's a little too much for me and I would like to continue to work with Markdown if possible.

I'm using MacTex on a Mac M1 and macOS Ventura updated to the latest version. Pandoc is on version 2.19.2. I think some TeX header-includes could help, but those used in the metadata.yaml don't seem to be the right ones.

  • 1
    @close voters: I think this is fine, LaTeX conversion with Pandoc is on-topic.
    – Marijn
    Commented Jan 12, 2023 at 9:48
  • Thanks for not closing. The solution just arrived from DG a little later, fantastic.
    – javipas
    Commented Jan 13, 2023 at 10:32

1 Answer 1


First a few remarks:

  1. Since 2018 you don't have to load chngcntr anymore
  2. The correct command to reset footnotes at every chapter is: \counterwithin*{footnote}{chapter}

But it still won't work because pandoc disables the chapter and section numbering by default, so there is no counter for the chapter within which the footnote counter could be reset.

This is fixed by enabling numbering with the option -N

pandoc test1.md test2.md metadata.yaml -N --output=test.pdf

If you really want to have unnumbered chapters, you could try Gonzalo Medinas solution for starred chapters here: https://tex.stackexchange.com/a/53533/29873

  • 1
    ¡¡Thank you!! Awesome, finally it does what I wanted!! The unnumbered chapters isn't a problem (at least, not now) but thank you anyway. Cheers DG!!
    – javipas
    Commented Jan 13, 2023 at 10:22
  • Btw @DG', one little update to the question. The footnotes appear at the end of the page. What if I want to show all the chapter footnotes at the end of that chapter?
    – javipas
    Commented Jan 17, 2023 at 17:07
  • @javipas -- I suggest, you ask a new question about endnotes, preferably focussing on the latex part only (i.e. leave out pandoc, and make a minimal working example (MWE) ). In the meantime you could have a look at the various endnote packages on ctan: ctan.org/topic/endnote
    – DG'
    Commented Jan 18, 2023 at 9:42
  • Great, thank you.
    – javipas
    Commented Jan 18, 2023 at 9:50
  • big thanks to @DG', this also fixed a weird bug with my markdown, that stopped restarting the numbering at every page, at chapter 5, and ended up finishing the letters in the alphabet, before the end of the book. I used \counterwithin*{footnote}{page}
    – simonpa71
    Commented Sep 9, 2023 at 20:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .