在 bookdown 中使用 csl-file 作为 pdf-output
use csl-file for pdf-output in bookdown
我想使用 .csl
文件来格式化 bookdown 的引用。将 csl: some-style.csl
添加到 index.Rmd
会影响 gitbook
的输出,但不会影响 pdf_book
。我知道我可以指定 biblio-style
,但这只接受一些标准样式而不接受 csl-files。有适当的解决方法吗?
重现步骤:
- 使用 RStudio 创建新项目并选择 "Book Project using bookdown" 作为选项。
- 从 https://www.zotero.org/styles 下载一些
.csl
文件并复制到项目的根目录。
- 将
csl: my_csl_file.csl
添加到index.Rmd
中的header。
- 将本书构建为 pdf 和 html,并观察参考文献中的差异(在参考文献部分或在简介中)
Header 在 index.Rmd
:
---
title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
csl: american-sociological-review.csl
link-citations: yes
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
---
HTML输出(正确):
PDF 输出(不正确):
我遇到了同样的问题。以下程序对我有用:
- 使用 RStudio 创建新项目并选择“Book Project using
bookdown”作为选项。
- 从 https://www.zotero.org/styles 下载一些 .csl 文件并复制到项目的根目录。就我而言:
chicago-author-date-de.csl
- 设置在_output.yml
citation_package: none
- 在 _output.yml 行
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
中添加所有格式(gitbook、pdf_book、epub_book)
- 删除或注释掉 index.Rmd 行
biblio-style: apalike
- 将06-references.Rmd的内容替换为
# References {-}
这是我的 _output.yml 文件:
bookdown::gitbook:
css: style.css
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
config:
toc:
before: |
<li><a href="./">A Minimal Book Example</a></li>
after: |
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: none
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
keep_tex: yes
bookdown::epub_book:
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
我想使用 .csl
文件来格式化 bookdown 的引用。将 csl: some-style.csl
添加到 index.Rmd
会影响 gitbook
的输出,但不会影响 pdf_book
。我知道我可以指定 biblio-style
,但这只接受一些标准样式而不接受 csl-files。有适当的解决方法吗?
重现步骤:
- 使用 RStudio 创建新项目并选择 "Book Project using bookdown" 作为选项。
- 从 https://www.zotero.org/styles 下载一些
.csl
文件并复制到项目的根目录。 - 将
csl: my_csl_file.csl
添加到index.Rmd
中的header。 - 将本书构建为 pdf 和 html,并观察参考文献中的差异(在参考文献部分或在简介中)
Header 在 index.Rmd
:
---
title: "A Minimal Book Example"
author: "Yihui Xie"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib, packages.bib]
csl: american-sociological-review.csl
link-citations: yes
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
---
HTML输出(正确):
PDF 输出(不正确):
我遇到了同样的问题。以下程序对我有用:
- 使用 RStudio 创建新项目并选择“Book Project using bookdown”作为选项。
- 从 https://www.zotero.org/styles 下载一些 .csl 文件并复制到项目的根目录。就我而言:
chicago-author-date-de.csl
- 设置在_output.yml
citation_package: none
- 在 _output.yml 行
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
中添加所有格式(gitbook、pdf_book、epub_book)
- 删除或注释掉 index.Rmd 行
biblio-style: apalike
- 将06-references.Rmd的内容替换为
# References {-}
这是我的 _output.yml 文件:
bookdown::gitbook:
css: style.css
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
config:
toc:
before: |
<li><a href="./">A Minimal Book Example</a></li>
after: |
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
download: ["pdf", "epub"]
bookdown::pdf_book:
includes:
in_header: preamble.tex
latex_engine: xelatex
citation_package: none
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
keep_tex: yes
bookdown::epub_book:
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]