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:
.csl
file from https://www.zotero.org/styles and copy to root of project.csl: my_csl_file.csl
to the header in index.Rmd
. 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:
chicago-author-date-de.csl
citation_package: none
pandoc_args: [ "--csl", "chicago-author-date-de.csl" ]
biblio-style: apalike
# 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" ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With