R Markdown:在“参考文献”后面放置附录?

6
我正在使用R Markdown写一份报告,其中包含参考文献。问题是R Markdown会自动将参考文献放在报告的末尾。我想在参考文献后添加一个附录,有什么办法可以做到吗?我看到可以使用子文档实现,但我希望所有内容都在一个唯一的.Rmd文件中。
下面是一个可重现的例子:
---
title:
author:
date: 
abstract: 

output: 
  pdf_document:
    template: NULL
    number_sections: true
    citation_package: biblatex
bibliography: references.bib
biblio-style: bwl-FU
---

# Partie 1

\cite{greenwood_financial_1989}

<!-- where I would like the references to be -->

# Appendix

bla bla 

这里是references.bib文件的内容:

@article{greenwood_financial_1989,
  title = {Financial Development, Growth and the Distribution of Income},
  url = {https://www.nber.org/papers/w3189},
  number = {3189},
  journaltitle = {NBER Working Paper Series},
  date = {1989},
  author = {Greenwood, Jeremy and Jovanovic, Boyan}
}

有任何想法吗?

2个回答

5

这在R Markdown Cookbook(第3.5.4节)中有解释。我们可以使用以下方式强制打印参考文献至特定位置:

# References

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

# Appendix

请注意:
- 如果我们使用@id_of_paper来引用文章(这是R Markdown中推荐的方法),则此方法有效,但如果使用\cite{id_of_paper}则无效。 - 如果在YAML中使用citation_package: biblatex则此方法将不起作用。
这是我改编后的示例:
---
title:
author:
date: 
abstract: 
output: 
  pdf_document:
    template: NULL
    number_sections: true
bibliography: references.bib
biblio-style: bwl-FU
---

# Partie 1

@greenwood_financial_1989


# References

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


# Appendix

bla bla 

3
如果使用
citation_package: biblatex

您可以使用以下方式在任意位置包含参考文献:

\printbibliography

这本身并不能阻止Pandoc添加(另一个)文档结尾的参考书目,但由于Pandoc在非LaTeX输出中忽略LaTeX,我们可以通过即时重新定义\printbibliography来抑制它。

因此,对于附录前的参考书目部分,请尝试以下操作:

# References

<div id="refs"></div>
\printbibliography[heading=none]
\def\printbibliography{}

# Appendix 1

Appendix goes here, and is not followed by a bibliography.

这个解决方案在使用 citation_package: biblatex 时非常好用,但是我认为添加 <div id="refs"></div> 是不必要的,因为 \printbibliography 命令正在做同样的事情。在我的情况下,包含该 div 命令意味着它会原样出现在我的参考文献列表顶部。 - Juan David Leongomez

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接