I want to add tables and figures after the bibliography in an R Markdown document. However, R Markdown documents will by default always add the bibliography to the end of the report.
Is there an easy way to add content to the document after the references?
Attempted Solutions
A previous answer showed that there is a way to put the appendix after the bibliography in R Markdown. This appendix is a separate file and is added to the document with after_body
in the YAML header. I tried 2 different possible solutions and none of them worked.
- I tried to put my appendix in a different file, but I ran into the problem of losing my references in the main file, as all the appendices are cross-referenced in the body of the paper. All references turn to ?? once I put them in a different file.
- I put all my figures and tables in a different file while also keeping them in the main file. Then, I used
results = "hide"
to hide them in the main file. The idea was to create 2 separate PDFs and to merge them. Unfortunately, when the figures are hidden, the references also turn to ??.
Additional information
- I am using the output format
bookdown:pdf_document2
- My figures are created by an
.R
file and imported into my R Markdown file withinclude_graphics()
.
<div id="refs"></div>
. I have noticed that the main difference is that my references are contained within abib
file, which is imported via the YAML header meanwhile the reference in your example is directly inside the YAML header. Do you think this is what causes the issue? – Logroll