在 bookdown 中使用 csl 文件进行 pdf 输出 [英] use csl-file for pdf-output in bookdown

查看:25
本文介绍了在 bookdown 中使用 csl 文件进行 pdf 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 .csl 文件来格式化带有 bookdown 的引用.将 csl: some-style.csl 添加到 index.Rmd 会影响到 gitbook 的输出,但不会影响 pdf_book.我知道我可以指定 biblio-style,但这仅接受一些标准样式而不接受 csl 文件.是否有适当的解决方法?

重现步骤:

  1. 使用 RStudio 创建新项目并选择Book Project using bookdown"作为选项.
  2. <小时>

    PDF 输出(不正确):

    解决方案

    我遇到了同样的问题.以下程序对我有用:

    1. 使用 RStudio 创建新项目并选择Book Project usingbookdown"作为选项.
    2. https://www.zotero.org/styles 下载一些 .csl 文件并复制到项目的根.就我而言:chicago-author-date-de.csl
    3. 在_output.yml中设置citation_package: none
    4. 在 _output.yml 中添加所有格式(gitbook、pdf_book、epub_book)的行 pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]立>
    5. 删除或注释掉 index.Rmd 行 biblio-style: apalike
    6. 将 06-references.Rmd 的内容替换为 # References {-}

    这是我的 _output.yml 文件:

    bookdown::gitbook:css:style.csspandoc_args: [ "--csl", "chicago-author-date-de.csl" ]配置:目录:之前: |<li><a href="./">一个最小的图书示例</a></li>之后: |<li><a href="https://github.com/rstudio/bookdown" target="blank">与 bookdown 一起发布</a></li>下载: ["pdf", "epub"]bookdown::pdf_book:包括:in_header: preamble.tex乳胶引擎:xelatexcitation_package: 无pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]keep_tex: 是bookdown::epub_book:pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]

    I would like to use a .csl-file for formatting references with bookdown. Adding csl: some-style.csl to index.Rmd affects the output to gitbook, but not to pdf_book. I know that I can specify biblio-style, but this only accepts some standard styles and not csl-files. Is there a proper workaround?

    Steps to reproduce:

    1. Create new project with RStudio and choose "Book Project using bookdown" as option.
    2. Download some .csl file from https://www.zotero.org/styles and copy to root of project.
    3. Add csl: my_csl_file.csl to the header in index.Rmd.
    4. Build the book to pdf and html, and observe the differences in the references (either in the references section, or in the introduction)

    Header in 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 output (correct):


    PDF output (incorrect):

    解决方案

    I had the same problem. The following procedure worked for me:

    1. Create new project with RStudio and choose "Book Project using bookdown" as option.
    2. Download some .csl file from https://www.zotero.org/styles and copy to root of project. In my case: chicago-author-date-de.csl
    3. Set in _output.yml citation_package: none
    4. Add in all formats (gitbook, pdf_book, epub_book) in _output.yml the line pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
    5. Delete or comment out in index.Rmd the line biblio-style: apalike
    6. Replace the content of 06-references.Rmd with # References {-}

    Here is my _output.yml file:

    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" ]
    

    这篇关于在 bookdown 中使用 csl 文件进行 pdf 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆