Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using short author citations in bookdown/rmarkdown

In my report, I'm citing the Standards for Educational and Psychological Testing by AERA, APA, and NCME.

@Book{standards,
  title = {{Standards for Educational and Psychological Testing}},
  author = {{American Educational Research Association} and {American Psychological Association} and {National Council on Measurement in Education}},
  shortauthor = {AERA},
  publisher = {American Educational Research Association},
  address = {Washington, DC},
  year = {2014}
}

According to APA style guide 6th ed., recognizable abbreviations for authoring organizations should be used. The first time I'm citing this book in the text, it should look like this:

Here is some filler text (American Educational Research Association [AERA], American Psychological Association, & National Council on Measurement in Education, 2014). And here is some more filler text (AERA et al., 2014).

However, my citations are currently showing like this:

Here is some filler text (American Educational Research Association, American Psychological Association, & National Council on Measurement in Education, 2014). And here is some more filler text (American Educational Research Association et al., 2014).

Is there a way to implement these citations in bookdown? A minimally reproducible example is here: https://github.com/wjakethompson/bookdown-citations

like image 611
Jake Thompson Avatar asked Jan 17 '18 14:01

Jake Thompson


2 Answers

I've developed a partially working solution. This solution prints the long author and shortened version, but only works for a single author, and as it uses LaTeX to achieve the customisation, it only works for PDF outputs.

Adapting your provided example, I have created a bibliography test.bib as follows:

@Book{standards2,
  title = {{Standards for Educational and Psychological Testing}},
  author = {{American Educational Research Association}},
  shortauthor = {AERA},
  publisher = {American Educational Research Association},
  address = {Washington, DC},
  year = {2014}
}

A file header.tex is also created. This defines a new LaTeX command \citefull, which prints out a citation in the format (author [shortauthor], year). The approach was loosely based off this answer here. The file content is as follows:

\DeclareCiteCommand{\citefull}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \DeclareNameAlias{labelname}{first-last}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   (\printnames{author}
   [\printnames{shortauthor}],
   {\printdate})
   }

  {\usebibmacro{postnote}}

% Adds a comma between the author and year
\renewcommand*{\nameyeardelim}{\addcomma\space}

Below is the Rmarkdown file. Changes are made to use biblatex as the citation package. To have a full citation, the command \citefull{} can be used.

---
output: 
  pdf_document:
    includes:
      in_header:  header.tex
    citation_package: biblatex
bibliography: test.bib
biblio-style: authoryear

---

\citefull{standards2}

[@standards2]

enter image description here


Additional Notes

As I said, this is a partial solution as it doesn't work for multiple authors, and I must admit my knowledge of customising LaTeX citations does not extend that far! Hopefully, someone will be able to expand on this answer to be able to improve this functionality.

I attempted using the solution explained here, but as it requires LaTeX packages to be loaded before biblatex, it would require the altering of the pandoc .tex template. I felt this was less optimal that using a header file.

Even if I did edit the original template, I was still having problems getting this solution working. I was getting an error \DeclareLanguageMappingSuffix and wasn't able to work out where I was messing things up.

I hope these notes help anyone who considers exploring a better solution.

like image 83
Michael Harper Avatar answered Sep 20 '22 01:09

Michael Harper


I was able to improve on the solution provided by Mikey Harper. It is still a partial solution only, since it uses LaTeX packages and therefore works only for PDF. The main idea is to use the this LaTeX solution and adapt it to RMarkdown. Content of test.bib:

@Book{standards,
  title = {{Standards for Educational and Psychological Testing}},
  author = {{American Educational Research Association} and {American Psychological Association} and {National Council on Measurement in Education}},
  shortauthor = {{AERA et al.}},
  publisher = {American Educational Research Association},
  address = {Washington, DC},
  year = {2014}
}

Rmd file:

---
output: 
  pdf_document:
    citation_package: biblatex
bibliography: test.bib
biblio-style: apa
biblatexoptions:
  - sortcites
header-includes:
  - \DeclareLanguageMapping{english}{american-apa}
---

[@standards]

[@standards]

Result: enter image description here

This is not quite the requested format, since the short author is at the end of author list, but according to this question, there is no better solution. I have therefore opened https://github.com/plk/biblatex-apa/issues/63.

like image 44
Ralf Stubner Avatar answered Sep 19 '22 01:09

Ralf Stubner