Bibliography Management

Citation, references and bibliography may take some times. Especially if you do not anticipate that.

Here are some tricks or solutions I have found for specific challenges and situations during the conversion of my materials into another type using R.

Referencing in Rmd

Quite simple, evenif you do not master BibTeX.

First step

You need a BibTeX file, with extension .bib. This is a simple text file containing description of the metadata of the references (title, author, year, etc.)

Bibtex uses a specific format as follows:

@article{RCoreTeam,
  Title   = {R: A Language and Environment for Statistical Computing},
  Author  = {{R Core Team}},
  Year    = {2015},
  Type    = {Journal Article},
  Url     = {http://www.R-project.org}
} 
@book{xie2016bookdown,
  title={Bookdown: Authoring Books and Technical Documents with R Markdown},
  author={Xie, Yihui},
  year={2016},
  publisher={CRC Press}
}

@article and @book identifies the reference type which may have specific fields (ex: publisher). Many other types exist.

Second step

In the YAML of your document after the output definition you add:

output: pdf_document
bibliography: [Liste_Publi1.bib]
link-citations: yes
nocite: '@*'
  • bibliography: indicates the .bib file or files and path : [Liste_Publi1.bib, common/Liste_Publi2.bib]
  • link-citations: yes: makes each citation linked to the reference in the bibliography section.
  • nocite: '@*': where '@*' is for all references in the bib file. You can choose specific references that are not cited in the text, but that you want appear in the bibliography:
nocite: |
  @item1, @item2

Third step

Finaly in your text, you add citation using @xie2016bookdown or [@xie2016bookdown] to abtain a citation without or with parentheses ( Xie (2016) or (Xie 2016) ).

Transforming a text references list into a Bibtex bibliography

Objective: Transform my 90 references list (.txt) into a BibTeX file (.bib).

I use text2bib free online tool, developped and maintained at Toronto University by Martin J. Osborne and Fabian Qifei Bai.

  • It requires to sign up for an account, but it is free and non intrusive.
  • Recognition of the fields of the references is partial (75%). It appears to be efficient for publication in journal and books, merely for inbook publication. For conferences, working paper, etc, some files have to be corrected (mainly copy-paste containt of erroneous fields to the correct one)
  • The limitation of text2bib is that you can not (or I do not find how to) change the proposed reference type when inappropriate (ex: from @article to @inbook)

Step by step approach:

  • step 1: upload the .txt file of your references list. In this file, each line is a standardized reference. References/lines are separated by blank line (return)
  • step 2: an interface displays the proposed bibtex data with precompletion of each field (author, year, journal, etc.).
  • step 3: once you have checked a reference, you validate with Add item to BibTeX file and continue
  • step 4: once you have checked all references (I have done 90 in less than 1 hour), click Display current BibTeX file (in new window) or Save current BibTeX file, to view or save the bibtex file agregating your checked references.

Finally I create a .rmd file containing all the references (see section above)

Sources:

Xie, Yihui. 2016. Bookdown: Authoring Books and Technical Documents with R Markdown. CRC Press.

Avatar
Iragaël Joly
Assistant Professor, Doctor in Economics & Data Scientist

My research interests include consumption and behavior econometric modelling applied to transport, food and innovative products.

Related