pandoc / lua-filters

A collection of lua filters for pandoc
MIT License
613 stars 166 forks source link

section-ref filter does not reset numbering of citations every chapter #82

Closed chemcoder-2020 closed 4 years ago

chemcoder-2020 commented 4 years ago

I am writing a thesis, for which I use pandocomatic and standard pandoc filters to convert multiple markdown files (chapters) to pdf. Using the section-ref filter, I was able to have a reference section for each chapter. However, the numbering doesn't reset for that chapter. If I repeat a citation in chapter 2, I would get the same numbering as the filter specified for chapter 1. The following is my header.md file which I use with pandocomatic.

---
pandocomatic:
    # use-templates: custom-cambria # uncomment when converting to docx
    pandoc:
        from: markdown
        to: pdf
        standalone: true
        toc: true
        number-sections: true
        template: ./templates/phdthesis # comment when converting to docx
        pdf-engine: xelatex
        include-in-header: ./templates/phdthesis_preamble.latex
        bibliography: ./library.bib
        # natbib: true  
        csl: ./acs-nano.csl
        papersize: letter
        mathjax: true
        filter:
            - pandoc-citeproc
            # - pandoc-crossref
            # - filters/pandoc-unicode-math
            # - filters/pandoc-unicode-math-from-latex
        top-level-division: chapter
        lua-filter:
            - ./section-refs.lua
            # - pagebreak/pagebreak.lua
            # - multiple-bibliographies/multiple-bibliographies.lua
        link-citations: true
        # reference-section-title: "References"
    metadata:
        author: Huy Nguyen
        mainfont: STIX
        sansfont: Noto Sans
        monofont: Noto Mono
        mathfont: XITS Math
        fontsize: 12 pt
        figPrefix: ['Fig.', 'Figs.']
        eqnPrefix: ['Eq.', 'Eqs.']
        tblePrefix: ['Table', 'Tables']
        geometry:
            - top=1in
            - bottom=1in
            - left=1in
            - right=1in
        header-includes:
            - \usepackage{siunitx}
            - \usepackage{unicode-math}
            - \usepackage{lmodern}
            - \usepackage{MnSymbol}
            # - \usepackage{physics}
---

<!-- Here I define some latex command to shorten my math -->

\newcommand{\bra}[1]{\left\langle#1\right|}
\newcommand{\ket}[1]{\left|#1\right\rangle}
\newcommand{\braket}[2]{\left\langle#1\right|\left.#2\right\rangle}
\newcommand{\mel}[3]{\left\langle#1\right|#2\left|#3\right\rangle}

Could I have some hint as to how to remedy this problem? I have tried to change the section-refs-level from the default of 1, but that didn't seem to do anything.

tarleb commented 4 years ago

I hope to look into this sometime later this week.

chemcoder-2020 commented 4 years ago

Thanks. I also added to the lua filter code the following to clear the duplicate references in case you want to merge that in as well.