bibliography does not render correctly after compiling bookdown

I have bibliography for each chapter. But after compiling my book the bibliography does not render correctly: it still has ## in front of every line.

I used to following code at the end of each chapter. e.g. "02.bib"

require("knitcitations")
cleanbib()
options("citation_format" = "pandoc")
read.bibtex(file = "02.bib")

#read.bib(file = "02.bib", package ="bibtex")

Ouput

## [1] A. Field, J. Miles, and Z. Field. _Discovering Statistics using R_.
## ISBN 978-1-4462-0045-2. California: Sage, 2013.
## 
## [2] R Core Team. _R: A Language and Environment for Statistical
## Computing_. R Foundation for Statistical Computing. Vienna, Austria,
## 2021. <URL: https://www.R-project.org/>.

How do I get rid of ## in the output.
please help.

Why not use citation directly from bookdown using what rmarkdown supports ?

Otherwise, I suppose you insert that in a chunk. The ## are usual line comment for output. If your function returns content to include asis you should adapt the chunk option or function.

Example for including content asis in the document - meaning output markdown to compile

Hope it helps

Thanks for the response.

First of all, I managed to get rid of ## in front of each bibliography item. by chunk option comment = "". Yet

[1] A. Field, J. Miles, and Z. Field. _Discovering Statistics using R_.
ISBN 978-1-4462-0045-2. California: Sage, 2013.

[2] D. Hosmer and S. Lemeshow. _Applied Logistic Regression_. ISBN
978-0-4705-8247-3. New York, NY: Wiley, 1989.

[3] R Core Team. _R: A Language and Environment for Statistical
Computing_. R Foundation for Statistical Computing. Vienna, Austria,
2021. <URL: https://www.R-project.org/>.

[4] A. Studenmund and H. Cassiday. _Using Econometrics, A Practical
Guide_. ISBN 978-0-6733-9137-7. Boston, MA: Little, Brown, 1987.

As you can see it still does not render correctly. Am I missing some packages?

I also tried what you suggested: list all bibliography items right after ## Reference. Then I got the following message:
pandoc-citeproc: reference Book not found
pandoc-citeproc: reference Book not found

Would you please help? Thanks,

I am not sure to understand what is the result you expect. Currently, what you are doing is reading a bib file directly into the markdown using read.bibtex() (I don't know this function).

Doing this way means it won't be processed by Pandoc to be including as citation for the chapter.

Usually, bib file are passed to bibliography field in YAML so that it is processed by Pandoc to be included.
Did you try putting your bib file like this ?

This would mean having one bib file with all you citation. But bookdown has a split_bib argument to split the bib at each chapter putting reference at the end of each chapter, and add the end of the book.

Did you try to follow bookdown feature for this ?

This is the yaml section in my index.Rmd

---
title: "The Little Machine Learning Book"
author: "Albert F. Lee, Ph.D."
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
output:
  bookdown::gitbook:
    lib_dir: assets
    split_by: section
    config:
      toolbar:
        position: static
  bookdown::pdf_book:
    keep_tex: yes
    citation_package: biblatex
  bookdown::html_book:
    css: toc.css
documentclass: book
bibliography: ["02.bib", "03.bib", "04.bib", "05.bib", "06.bib", "07.bib", "08.bib",
               "09.bib", "10.bib", "13.bib", "11.bib", "12.bib"]
biblio-style: "apalike"
link-citations: true
---

and this is the output of Reference at the end of Chapter 2
??? ){field2013, title = {Discovering Statistics using R}, author = {Field, A. and Miles, J. and Field, Z.}, publisher = {Sage}, address = {California}, year = {2013}, note = {ISBN 978-1-4462-0045-2} }

( ??? ){Hosmer1989, title = {Applied Logistic Regression}, author = {Hosmer, D.W. and Lemeshow, S.}, publisher = {Wiley}, address = {New York, NY}, year = {1989}, note = {ISBN 978-0-4705-8247-3} }

I am re-reading the book and still can't figure out how to fix it. As you can see I have 12 chapters in my book and at the end of each chapter (.Rmd) I have a reference in "02.bib" in this case.

And this what I have at the end of 02-LR.Rmd.

I am just trying to publish the book with correct reference. It is frustrating, no less.

please help. Thanks,

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.