Skip to content

Latest commit

 

History

History
88 lines (68 loc) · 3.77 KB

citations_knit_.md

File metadata and controls

88 lines (68 loc) · 3.77 KB

This gives a quick example about how we can add citations into a markdown file with the same ease that we can in latex. I illustrate two different ways to get citation information. In the first example we look up the metadata automatically given the digital object identifier (doi) for the paper.

In the second example we will read in a bibliography in bibtex format using the bibtex package, which can then be expressed in markdown immediately.

Next I create an inline citation function that can take either a list of doi's or bibentry topics and format them into inline citations, while also storing this information to generate the full bibliography later.

DOI Approach

The crossref function is available in the rplos package 0.0-6, (use the github copy, not in the CRAN version yet)

Bibtex approach

For convenience let's write the entry we pulled with crossref to a bibfile, just to get a simple bibfile as our starting point.

We simply read in any bibtex file and print the citation:

Now this would be much more awesome if we could generate keys on write.bib and use those bibtex keys, instead of the index value, [[1]], to generate the citation.

Inline citations

The other thing we need is a way to print inline citations that would just use a given shortened format (e.g. author-year, or a number) and add the citation to a works_cited object, which we could then use to generate the full citation information at the end.

Note that the function can take a list of objects (though I'll have to clean up their formatting), and it can take either dois or the biblio list from above. It would be easy to write the textual citation formatting and number formatting too. I may add these to a simple R package for that purpose.

Now we can gereate inline citations like this . Hmm, looks like we need a way for rinline code to use asis formatting though.

Bibliography

Then at the end of the document, use this command to print the bibliography generated by the use of our inline citations.

Like many others on this list, I finding myself more and more drawn to markdown rather then tex/Rnw as my standard format (not least of which is the ease of displaying the files on github, particularly now that we have automatic image uploading). One thing I miss from latex is the citation commands.

I've taken a little whack at generating parenthetical citations