如果没有手动编辑生成的.tex文件,则不会引用PDF

问题描述 投票:0回答:1

我试图让我的出版物进入R-Markdown,特别是使用rticles包,但我遇到引用问题。目标是让natbib选项运行,这样引用就不会被pandoc“硬编码”了。

我熟悉本网站上的以下主题及其中的参考资料,但这并未提供解决方案:natbib-seems-to-not-work-properly-with-pdf-book-rticles

每当我使用natbib选项'编织'文章时,我的引用仍未定义。我能找到的唯一解决方案是通过keep_tex: true选项并在编译后手动添加\bibliography命令。我无法想象这实际上需要使引文起作用。

我尝试过的,我能想到的最好的是rticles提供的模板的以下修改发布如下。我发现让它运行的唯一方法实际上是打开生成的.tex文件,然后在\end{document}添加行\bibliography{mybibfile},这可能不是预期的。

任何人都可以重现我的问题,我只是遗漏了一些东西,或者是在包装方面的问题更多?

---
title: Short Paper
author:
  - name: Alice Anonymous
    email: [email protected]
    affiliation: Some Institute of Technology
    footnote: Corresponding Author
address:
  - code: Some Institute of Technology
    address: Department, Street, City, State, Zip
journal: "An awesome journal"
date: "`r Sys.Date()`"
bibliography: mybibfile.bib
output: 
  bookdown::pdf_book:
    citation_package: natbib
    base_format: rticles::elsevier_article
    number_sections: yes
    keep_tex: true
---

Bibliography styles
===================

Here are two sample references: @Feynman1963118 [@Dirac1953888].

References {#references .unnumbered}
==========

以下mybibfile.bib

@article{Dirac1953888,
  title   = "The lorentz transformation and absolute time",
  journal = "Physica ",
  volume  = "19",
  number  = "1-–12",
  pages   = "888--896",
  year    = "1953",
  doi     = "10.1016/S0031-8914(53)80099-6",
  author  = "P.A.M. Dirac"
}

@article{Feynman1963118,
  title   = "The theory of a general quantum system interacting with a linear dissipative system",
  journal = "Annals of Physics ",
  volume  = "24",
  pages   = "118--173",
  year    = "1963",
  doi     = "10.1016/0003-4916(63)90068-X",
  author  = "R.P Feynman and F.L {Vernon Jr.}"
}
r-markdown bookdown citations
1个回答
0
投票

有时参考部分没有出现,因为从RMarkdown通过LaTeX编写PDF时没有指定参考书目样式。根据the official document,您可以在YAML部分设置biblio-style,如下所示:

bibliography: mybibfile.bib
biblio-style: apa #whatever style you want
© www.soinside.com 2019 - 2024. All rights reserved.