Citations in PDFs produced by Bookdown are incorre

2020-07-24 09:57发布

I am making a book with bookdown. The HTML version renders exactly as I would expect it to.

For example, the

5. Read Chapter 7 of Myers
  [-@myers_2013_qualitativeresearchbusiness p. 73--91] — 60 minutes.

Renders correctly as:

  1. Read Chapter 7 of Myers (2013, pp. 73–91) — 60 minutes.

However, in the PDF version the citation is rendered as the bibtex key; i.e.,

5. Read Chapter 7 of Myers (myers_2013_qualitativeresearchbusiness) — 60 minutes.

My script does the follwing to make the pdf.

Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book')"

and my _output.yml looks like this:

bookdown::gitbook:
  css: style.css
  split_bib: no
  config:
    toc:
      collapse: section
      before: |
        <li><a href="./">Qualitative Research Methods</a></li>
      after: |
        <li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
    edit: https://github.com/psmith1303/business705/edit/master/%s
    download: ["pdf", "epub"]
bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: lualatex
  citation_package: biblatex
  keep_tex: yes
bookdown::epub_book: default

The actual pandoc command that gets run at the end of all this is:

/usr/local/bin/pandoc +RTS -K512m -RTS business705.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output business705.tex --table-of-contents --toc-depth 2 --template /usr/home/psmith/NAS/Programming/R/Libs/rmarkdown/rmd/latex/default-1.17.0.2.tex --number-sections --highlight-style tango --latex-engine lualatex --biblatex --include-in-header preamble.tex --variable graphics=yes --variable 'geometry:margin=1in' --variable tables=yes --standalone --bibliography book.bib 

I suspect I need to run the latex 'engine' again to to get the citations right, but I can't figure out how to do that.

1条回答
来,给爷笑一个
2楼-- · 2020-07-24 10:30

So, the fix seems to have been to move from pdflatex to xelatex as the LaTeX engine. I did this by changing _output.yml

bookdown::gitbook:
  css: style.css
  split_bib: no
  config:
    toc:
      collapse: section
      before: |
        <li><a href="./">Qualitative Research Methods</a></li>
      after: |
        <li><a href="https://github.com/rstudio/bookdown" target="blank">Published     with bookdown</a></li>
    edit: https://github.com/psmith1303/business705/edit/master/%s
    download: ["pdf", "epub"]
bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: xelatex
  citation_package: biblatex
  keep_tex: yes
bookdown::epub_book: default

(That was a non-trivial exercise for me, I had to throw out my texlive installation, and switch to TinyTex to get biber working correctly).

查看更多
登录 后发表回答