9

I currently render my thesis with Markdown files as source, and want to generate a PDF output. I use the following command for that:

pandoc --template template.latex --standalone --chapters \
       -V linestretch=1.5 --toc --number-sections --bibliography sources.bib \
          00_title.md 01_introduction.md \
          02_state-of-the-art.md 03_implementation.md 04_discussion.md \
          05_conclusion.md \
       -o thesis.pdf

I would like to also set the bibliography title, since it currently doesn't appear, and the sources are just attached right after the last sentence.

I have already tried to add -V biblio-title=Bibliography, because it seems like this is the variable used in the LaTeX template. It didn't fail, but it seems to just ignore this value.

So how can the title of the bibliography be correctly set?

0

2 Answers 2

15

Update: Since the original answer in 2015 the command line interface of pandoc has changed, e.g. the built-in mechanism needs the option --citeproc and -S/--smart is an extension in recent versions. I changed the the answer to reflect this. The most up-to-date documentation can, of course, be found in the manual.

Short answer

  • For the built-in mechanism use: --citeproc -M reference-section-title=Whatever (see Art's answer)
  • For biblatex/natbib use: --biblatex or --natbib and -V biblio-title=Whatever

Long answer

If you are producing LaTeX output with pandoc you have three options for the bibliography: (1.) The built-in mechanism citeproc, (2.) natbib, or (3.)biblatex.

1. Buit-in mechanism

The built-in mechanism (citeproc) writes the bibliographic information without heading at the end of the file. Just end your document with a heading of your choosing:

test.bib:

@article{doe1905,
 author={Doe, John},
 title={Title},
 journal={Journal},
 year={1905},
}

test.md:

# Test

This is a test [@doe1905].

# Bibliography

Command: pandoc --citeproc --bibliography=test.bib -o test.pdf test.md

enter image description here

Changing the title of the bibliography: With citeproc you can either give the last section, at the very end of the document, the title you want, or you could set the name with the option -M reference-section-title=Whatever: pandoc --citeproc --bibliography=test.bib -M reference-section-title=Whatever -o test.pdf test.md

This has the advantage, that it will produce consistent output also for other formats like Microsoft Word (.docx) or Open/Libre Office (.odt).

2. Natbib

Use natbib to produce a .tex file and compile it afterwards with latexmk, arara or whatever tool you like:

Command: pandoc --standalone --natbib --bibliography=test.bib -o test.tex test.md && latexmk test.tex

enter image description here

Changing the title of the bibliography: pandoc --standalone --natbib --bibliography=test.bib -V biblio-title=Whatever -o test.tex test.md && latexmk test.tex will give you:

enter image description here

3. Biblatex

Use biblatex to produce a .tex file and compile it afterwards with latexmk, arara or whatever tool you like:

Command: pandoc --standalone --biblatex --bibliography=test.bib -o test.tex test.md && latexmk test.tex

enter image description here

Changing the title of the bibliography: pandoc --standalone --biblatex --bibliography=test.bib -V biblio-title=Whatever -o test.tex test.md && latexmk test.tex will produce:

enter image description here

3
  • What is the purpose of specifying the -s flag twice?
    – user32882
    Commented Feb 27, 2023 at 16:11
  • @user32882 — One is standalone, the other used to be smart, but has been moved to reader and/or writer options in more recent versions of pandoc
    – DG'
    Commented Feb 27, 2023 at 20:45
  • What does -S actually do?
    – user32882
    Commented Feb 28, 2023 at 4:27
2

If you're using citeproc, you can put in reference-section-title in the metadata.

https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md

pandoc --template template.latex --standalone --chapters \
       -V linestretch=1.5 --toc --number-sections --bibliography sources.bib \
       -M reference-section-title=References \
          00_title.md 01_introduction.md \
          02_state-of-the-art.md 03_implementation.md 04_discussion.md \
          05_conclusion.md \
       -o thesis.pdf
2
  • Thank you. Would be helpful, if you could add a screenshot showing relevant results from your approach. Thanks
    – MS-SPO
    Commented Apr 26, 2022 at 8:42
  • @MS-SPO Not sure as I do not have the source files mentioned. But it looks exactly like this i.sstatic.net/GC5X0.png produced in the answer above.
    – Art
    Commented Apr 26, 2022 at 9:18

You must log in to answer this question.

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