Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandoc insert appendix after bibliography

I'm using the knitr package and pandoc in R to convert a .Rmd file to a PDF. Pandoc is linked to a .bib file and automatically inserts the bibliography at the end of the PDF The entries in my .bib file look like these, taken from http://johnmacfarlane.net/pandoc/demo/biblio.bib:

@Book{item1,         author="John Doe",         title="First Book",         year="2005",         address="Cambridge",         publisher="Cambridge University Press"   }  @Article{item2,          author="John Doe",          title="Article",          year="2006",          journal="Journal of Generic Studies",          volume="6",          pages="33-34" } 

To build my bibliography, I'm using the following function, taken from: http://quantifyingmemory.blogspot.co.il/2013/02/reproducible-research-with-r-knitr.html

knitsPDF <- function(name) {   library(knitr)   knit(paste0(name, ".Rmd"), encoding = "utf-8")   system(paste0("pandoc -o ", name, ".pdf ", name, ".md --bibliography /Users/.../Desktop/test.bib --csl /Users/.../Desktop/taylor-and-francis-harvard-x.csl")) } 

The contents of my .Rmd file is:

This is some text [@item1]  This is more text [@item2]  # References 

And outputted PDF looks like this:

enter image description here

If I try to insert an appendix, the references still print at the end of the document, like this:

enter image description here

How do insert an appendix after the references?

like image 752
luciano Avatar asked May 07 '13 20:05

luciano


People also ask

How do you add an appendix after a bibliography in LaTeX?

Adding an appendix to your document in LaTeX is as easy as invoking the macro \appendix . From the moment you call this command, the new chapters will be numbered using capital letters, and instead of `Chapter' they will be called `Appendix'.

How do you use extensions in Pandoc?

An extension can be enabled by adding +EXTENSION to the format name and disabled by adding -EXTENSION . For example, --from markdown_strict+footnotes is strict Markdown with footnotes enabled, while --from markdown-footnotes-pipe_tables is pandoc's Markdown without footnotes or pipe tables.

Does R markdown use Pandoc?

R Markdown (package)This function 'renders the input file to the specified output format using pandoc. If the input requires knitting then knitr::knit is called prior to pandoc. The RMarkdown package's aim is simply to provide reasonably good defaults and an R-friendly interface to customize Pandoc options..

Can Pandoc convert HTML to Markdown?

Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.


2 Answers

With newer pandoc versions, you can specify the bibliography's position with <div id="refs"></div> source

This is some text [@item1]  This is more text [@item2]  # References  <div id="refs"></div>  # appendix 
like image 81
scoa Avatar answered Sep 22 '22 05:09

scoa


Eventually reference handling will change to make it possible to put the references wherever you like (https://github.com/jgm/pandoc/issues/771), but right now there's no easy way to do it.

As suggested here, you could put your appendix in a separate file, use pandoc to convert it to a LaTeX fragment, then include that fragment using the --include-after-body flag. It would then come after the bibliography.

like image 36
John MacFarlane Avatar answered Sep 21 '22 05:09

John MacFarlane