bookdown::word_document2, reference_docx does not work with bibliography

Problem

When I include 'reference_docx' in yaml header, knit fails.
Here is the yaml failed.

output: bookdown::word_document2
(indenced) reference_docx: chapter_style.docx
bibliography: library.bib
csl: apa.csl

This generates the error message as below:

Error in yaml::yaml.load(..., eval.expr = TRUE) :
Scanner error: mapping values are not allowed in this context at line 2, column 17
Calls: ... parse_yaml_front_matter -> yaml_load ->
Execution halted

Without reference_docs, it works

Here is the yaml that works fine.

output: bookdown::word_document2
(indensed, deactivated) # reference_docx: chapter_style.docx
bibliography: library.bib
csl: apa.csl

Here is the successful result:

processing file: chapter_game_industry.Rmd
|.................................................................| 100%
ordinary text without R code

output file: chapter_game_industry.knit.md

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS chapter_game_industry.utf8.md --to docx --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output chapter_game_industry.docx --highlight-style tango --filter /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc-citeproc

Output created: chapter_game_industry.docx

Does anyone know how to use .docx with the bibliography option?

Make sure that the indents are in the correct places within your YAML header for not only reference_docx but also for the output you're using.

bookdown::word_document2 should be in its own indented line and with a : at the end because you're adding settings to it.

Your YAML should look something like:

output:
  bookdown::word_document2:
    reference_docx: chapter_style.docx
bibliography: library.bib
csl: apa.csl
4 Likes

The problem is solved.

Thank you very much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.