代码之家  ›  专栏  ›  技术社区  ›  Thomas K

在bookdown中使用csl文件进行pdf输出

  •  9
  • Thomas K  · 技术社区  · 7 年前

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

    复制步骤:

    1. 使用RStudio创建新项目,并选择“使用bookdown预订项目”作为选项。
    2. 下载一些 .csl公司 文件来源 https://www.zotero.org/styles 并复制到项目的根目录。
    3. 添加 csl: my_csl_file.csl 至中的标题 指数Rmd .
    4. 将本书构建为pdf和html格式,并观察参考文献中的差异(参考文献部分或简介中)

    标题输入 指数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输出(正确): enter image description here


    PDF输出(不正确): enter image description here

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  11
  •   petzi    7 年前

    我也有同样的问题。以下程序对我有效:

    1. 使用RStudio创建新项目并选择“Book project using “bookdown”作为选项。
    2. 下载一些。csl文件来自 https://www.zotero.org/styles 并复制到项目的根目录。就我而言: chicago-author-date-de.csl
    3. 在输出中设置。yml公司 citation_package: none
    4. 在输出中添加所有格式(gitbook、pdf\u book、epub\u book)。yml线路 pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
    5. 在索引中删除或注释掉。Rmd线路 biblio-style: apalike
    6. 替换06参考文献的内容。Rmd带 # References {-}

    这是我的\u输出。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" ]