Sav*_*SUS 7 r cross-reference r-markdown bookdown
我想在 R Markdown 文档中的参考书目之后添加表格和数字。但是,默认情况下,R Markdown 文档将始终将参考书目添加到报告的末尾。
有没有一种简单的方法可以在引用后向文档添加内容?
一个以前的答案表明,就是把附录中的R在降价后书目的方式。此附录是一个单独的文件,并after_body通过 YAML 标头添加到文档中。我尝试了 2 种不同的可能解决方案,但都没有奏效。
results = "hide"将它们隐藏在主文件中。这个想法是创建 2 个单独的 PDF 并合并它们。不幸的是,当数字被隐藏时,参考也变成了?? .bookdown:pdf_document2.R文件创建的,并使用include_graphics().Mic*_*per 10
与其试图在 after_body 中包含内容,不如重新定位参考书目在文档中出现的位置。如本答案所述,您可以使用<div id="refs"></div>.
其次,您可以使用 bookdown 在文档中轻松添加附录。使用标题# (APPENDIX) Appendix {-}会将所有后续部分编号从数字更改为字母。查看bookdown书
在完整示例中使用:
---
title: "Untitled"
output: bookdown::pdf_document2
references:
- id: fenner2012a
title: One-click science marketing
author:
- family: Fenner
given: Martin
container-title: Nature Materials
volume: 11
URL: 'http://dx.doi.org/10.1038/nmat3283'
DOI: 10.1038/nmat3283
issue: 4
publisher: Nature Publishing Group
page: 261-263
type: article-journal
issued:
year: 2012
month: 3
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(magrittr)
```
# Introduction
Here is a citation [@fenner2012a]
# References {-}
<div id="refs"></div>
\newpage
# (APPENDIX) Appendix {-}
# Appendix A
Here is your table
```{r table, fig.pos="H"}
knitr::kable(mtcars[1:5, 1:5], caption = "A table") %>%
kableExtra::kable_styling(latex_options = "HOLD_position")
```
Run Code Online (Sandbox Code Playgroud)
注意:这仅在您使用 pandoc 的内置引文包时有效,如果您
citation_package: natbib在 YAML 中设置则无效