[Tex/LaTex] Transform markdown to pdf with APA style and bibtex support

bibliographiesbibtexpandoc

According to pandoc's documentation, raw LaTeX can be used to insert citations inside a markdown file with \cite{foo}. This is what I've tried to accomplish that:

pandoc -s --template=template.latex  -f markdown+raw_tex draft2.md  -o final.pdf 

Everything runs fine except for the bibliography and the quotations. I also tried this (but I have no idea what it does):

pandoc -s -S --filter pandoc-citeproc --biblio all.bib --csl apa6.csl 
   --latex-engine=xelatex --template=template.latex  --variable
   mainfont="Georgia" --variable fontsize=12pt Draft.md  -o FINISHED.pdf

My template file is here.

Best Answer

When you specify a PDF output file, pandoc will run pdflatex or xelatex for you to create it. However, pandoc does not attempt to run bibtex or biber. So, if you want to use native latex citations, you should first produce a tex file:

pandoc -s --template=template.latex  -f markdown+raw_tex draft2.md -o final.tex

Then,

pdflatex final.tex
bibtex final.tex
pdflatex final.tex
pdflatex final.tex

I would use a Makefile to automate these procedures. Alternatively, you can use pandoc's native citation format (instead of raw latex) -- see the pandoc User's Guide for information on this. If you did that, the second command you gave would work. With this method, pandoc uses its own citation processor (pandoc-citeproc), using CSL stylesheets, instead of bibtex or biber. An advantage of this method is that it works in every output format.