如何在 Bookdown 中更改为另一种书目样式
How to change to another bibliography style in Bookdown
我想在 Bookdown 中使用另一种书目风格而不是 apalike,当我更改为数字风格的 nature 并构建这本书时,它提示我,
����: Failed to build the bibliography via bibtex
Please delete bookdown.Rmd after you finish debugging the error.
ִֹͣ��
Exited with status 1.
有解决办法吗?
标题作者和描述中有一些汉字,是这个原因吗?
YAML header
---
title: "title"
author: "aa"
date: "`r Sys.Date()`"
documentclass: ctexbook
bibliography: [book.bib]
biblio-style: nature
link-citations: yes
colorlinks: yes
lot: no
lof: no
geometry: [b5paper, tmargin=2.5cm, bmargin=2.5cm, lmargin=3.5cm, rmargin=2.5cm]
site: bookdown::bookdown_site
description: "dd。"
github-repo: yihui/bookdown-chinese
#cover-image: images/cover.jpg
---
Session:
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 rstudioapi_0.7 xml2_1.2.0 knitr_1.20 magrittr_1.5 xtable_1.8-2
[7] R6_2.2.2 rlang_0.2.0 bibtex_0.4.2 plyr_1.8.4 httr_1.3.1 stringr_1.3.1
[13] tools_3.5.0 xfun_0.1 miniUI_0.1.1 htmltools_0.3.6 yaml_2.1.19 assertthat_0.2.0
[19] rprojroot_1.3-2 digest_0.6.15 bookdown_0.7 RefManageR_1.2.0 later_0.7.2 promises_1.0.1
[25] curl_3.2 evaluate_0.10.1 mime_0.5 rmarkdown_1.9 stringi_1.1.7 compiler_3.5.0
[31] citr_0.2.0 backports_1.1.2 lubridate_1.7.4 jsonlite_1.5 httpuv_1.4.3
您指定了 bibtex 样式 nature.bst
,但您的系统不提供该样式。我在 CTAN 上也找不到它。在 CTAN 上搜索有两件事:
- 包括
naturemag.bst
的nature package
- biblatex-nature package 为 biblatex 添加自然类引用
所以要么使用
biblio-style: naturemag
或(首选,见下文)使用
切换到 biblatex
bookdown::pdf_book:
citation_package: biblatex
在 _output.yml
中。在这两种情况下,您都必须确保安装了所需的 TeX 包。这取决于 TeX 分布。在我的例子中(为 Debian 打包的 TeXLive)这意味着
sudo apt-get install texlive-publishers texlive-bibtex-extra
对于 TeXLive 或 TinyTeX,您可以在命令行上使用:
tlmgr install nature
tlmgr install biblatex-nature
对于 TinyTeX,您也可以在 R 中执行此操作:
library(tinytex)
tlmgr_install('nature')
tlmgr_install('biblatex-nature')
有关详细信息,请参阅 maintenance section。
不幸的是,只有 bbilatex
解决方案与 bookdown
生成的默认引用命令兼容。人们可能会更改引文的插入 LaTeX 命令,但这会使生成其他格式更加复杂。此外,对于 LaTeX 中的许多参考书目问题,biblatex
是 "the way to go" ...
- 从 https://www.zotero.org/styles?q=nature 下载您的 .csl 文件
并将其复制到项目的根目录。
- 设置在_output.yml
citation_package: none
- 添加所有格式(gitbook,pdf_book,
epub_book) 在 _output.yml 行
pandoc_args: [ "--csl",
"your-csl-file.csl" ]
- 删除或注释掉 index.Rmd 行
biblio-style: apalike
查看完整程序
我想在 Bookdown 中使用另一种书目风格而不是 apalike,当我更改为数字风格的 nature 并构建这本书时,它提示我,
����: Failed to build the bibliography via bibtex
Please delete bookdown.Rmd after you finish debugging the error.
ִֹͣ��
Exited with status 1.
有解决办法吗? 标题作者和描述中有一些汉字,是这个原因吗?
YAML header
---
title: "title"
author: "aa"
date: "`r Sys.Date()`"
documentclass: ctexbook
bibliography: [book.bib]
biblio-style: nature
link-citations: yes
colorlinks: yes
lot: no
lof: no
geometry: [b5paper, tmargin=2.5cm, bmargin=2.5cm, lmargin=3.5cm, rmargin=2.5cm]
site: bookdown::bookdown_site
description: "dd。"
github-repo: yihui/bookdown-chinese
#cover-image: images/cover.jpg
---
Session:
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936
[3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C
[5] LC_TIME=Chinese (Simplified)_China.936
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 rstudioapi_0.7 xml2_1.2.0 knitr_1.20 magrittr_1.5 xtable_1.8-2
[7] R6_2.2.2 rlang_0.2.0 bibtex_0.4.2 plyr_1.8.4 httr_1.3.1 stringr_1.3.1
[13] tools_3.5.0 xfun_0.1 miniUI_0.1.1 htmltools_0.3.6 yaml_2.1.19 assertthat_0.2.0
[19] rprojroot_1.3-2 digest_0.6.15 bookdown_0.7 RefManageR_1.2.0 later_0.7.2 promises_1.0.1
[25] curl_3.2 evaluate_0.10.1 mime_0.5 rmarkdown_1.9 stringi_1.1.7 compiler_3.5.0
[31] citr_0.2.0 backports_1.1.2 lubridate_1.7.4 jsonlite_1.5 httpuv_1.4.3
您指定了 bibtex 样式 nature.bst
,但您的系统不提供该样式。我在 CTAN 上也找不到它。在 CTAN 上搜索有两件事:
- 包括
naturemag.bst
的nature package
- biblatex-nature package 为 biblatex 添加自然类引用
所以要么使用
biblio-style: naturemag
或(首选,见下文)使用
切换到 biblatexbookdown::pdf_book:
citation_package: biblatex
在 _output.yml
中。在这两种情况下,您都必须确保安装了所需的 TeX 包。这取决于 TeX 分布。在我的例子中(为 Debian 打包的 TeXLive)这意味着
sudo apt-get install texlive-publishers texlive-bibtex-extra
对于 TeXLive 或 TinyTeX,您可以在命令行上使用:
tlmgr install nature
tlmgr install biblatex-nature
对于 TinyTeX,您也可以在 R 中执行此操作:
library(tinytex)
tlmgr_install('nature')
tlmgr_install('biblatex-nature')
有关详细信息,请参阅 maintenance section。
不幸的是,只有 bbilatex
解决方案与 bookdown
生成的默认引用命令兼容。人们可能会更改引文的插入 LaTeX 命令,但这会使生成其他格式更加复杂。此外,对于 LaTeX 中的许多参考书目问题,biblatex
是 "the way to go" ...
- 从 https://www.zotero.org/styles?q=nature 下载您的 .csl 文件 并将其复制到项目的根目录。
- 设置在_output.yml
citation_package: none
- 添加所有格式(gitbook,pdf_book,
epub_book) 在 _output.yml 行
pandoc_args: [ "--csl", "your-csl-file.csl" ]
- 删除或注释掉 index.Rmd 行
biblio-style: apalike
查看完整程序