20

I'm currently writing my bachelor thesis and my instructor wants me to put my appendix after the bibliography but markdown/pandoc puts the references at the end by default. I read the instructions at http://yihui.name/knitr/demo/pandoc/ and tried to use the include-after-body=FILE command to put a separate .rmd file at the end of the document My code looks like this:

```{r, echo=FALSE, warning=FALSE, message=FALSE}
library(knitr)
pandoc('thesis.rmd', format="latex")
```

and for the options:

<!--pandoc
t: latex
include-after-body: appendix.rmd
o: output.pdf
-->

Where appendix.rmd is the separate appendix file.

After klicking on convert pdf, the process gets stuck with an error after the line executing pandoc --include-after-body=appendix.rmd -o thesis.pdf -f markdown -t latex -o thesis.pdf "thesis.utf8md"

The error is:

pandoc.exe: Error producing PDF from TeX source.

Is there something wrong with the code or is there some other method to remove the bibliography from the end of the document?

2
  • 1
    Very interesting question, would like to do exactly the same! Commented Aug 21, 2015 at 17:20
  • Well it's been a while since I had the problem so maybe there is another solution but I used a workaround which is a bit messy but it did the job. I first created a pdf without the appendix and the bibliography at the end and afterwards created another pdf which only contained the appendix, without page numbers and put the two pdf documents together. I know it's not ideal but my thesis advisor was fine with it, so maybe it helps you as well. Commented Aug 22, 2015 at 18:57

3 Answers 3

21

You can place your bibliography wherever you like by inserting

::: {#refs}
:::

wherever you want the bibliography printed. From the "Placement of the bibliography" section of the pandoc markdown manual.

For example:

...main body

# References

::: {#refs}
:::

# Appendix
Sign up to request clarification or add additional context in comments.

pandoc.org/MANUAL.html#placement-of-the-bibliography is probably a more accurate link to the documentation for what you are discussing.
Apparently this only works for certain styles ("If the style calls for a list of works cited, it will be placed in a div with id refs, if one exists"). For instance, the eisvogel template does not support this.
20

There is another solution:

<div id="refs"></div>

It lets you put the references wherever you want.

For me, this did the trick! Thank you! Note: it also works for docx.
I don't think this trick works with LaTeX output, as the OP seemed to want.
It also works for LaTeX, but not properly in combination with biblatex.
0

I just figured out that it works when you use a tex file, like --include-after-body=appendix.tex. I'm not an RMarkdown or Tex expert at all but I could imagine that it will only include the file after your main Rmd is already converted to a tex file using the default template.

Comments

Your Answer

Draft saved
Draft discarded

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.