jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.81k stars 3.39k forks source link

docx, citeproc, and the bibliography section #10325

Closed terris-peer closed 1 month ago

terris-peer commented 1 month ago

Describe your proposed improvement and the problem it solves.

Pandoc 3.5 with pandoc-crossref 0.3.18-b, AMD64, Debian.

When using markdown input, docx output, the citeproc filter, and pandoc-crossref, the last section in the document contains the bibliography and is not numbered. This appears to be intentional. See referenced issue (from 2014) below. There are two problems with this for me: first, I would like the bibliography to appear in a section named # REFERENCES (as per the Pandoc docs, but it doesn't seem to work) which is not the last section, and secondly, I would like this section to be numbered.

Referenced issue:

          I've dealt with this, for now, by having pandoc-citeproc insert the `unnumbered` class into the final header.  This avoids the problem of pandoc numbering it incorrectly, and conforms to the general principle that bibliography sections aren't numbered.

Originally posted by @jgm in https://github.com/jgm/pandoc/issues/1277#issuecomment-42124331

Describe alternatives you've considered.

  1. Rearranging --number-sections and --filter
  2. Turning it off and on again
  3. Selling my soul
  4. Acceptance
pandoc --from markdown --to docx
--standalone
--reference-doc=...
--number-sections', # Each heading specified by # is numbered sequentially
--filter # must be before --citeproc
pandoc-crossref', # must be before --citeproc
--citeproc
--bibliography=...
-M link-citations=true
-M chapters # Table and figure numbers are prefixed by their section numbers
-M linkReferences # @tbl: and @fig: have hyperlinks
njbart commented 1 month ago

A proper MWE would have been appreciated. Still, try this:

pandoc --number-sections -s --citeproc -o test.docx << EOT
---
references:
- id: item1
  type: book
  author:
    - family: Doe
      given: Jane
  issued: 2020
  title: The title
...

# Section One

[@item1]

# References

::: {#refs}
:::

EOT

Output:

Screenshot
terris-peer commented 1 month ago

Holy moly! That works! I would have never found it even with ChatGPT (or google). Thaaaaank yooooooooooooou!

::: {#refs}
:::