Search code examples
r-markdownpapaja

citing meta-analytic sources in papaja


I'm writing up a meta-analysis and I would like to cite papers from the meta-analysis in the bibliography with an asterisks before the last name. I'm able to use the nocite function in the reference section to include references not cited in the text, but I need to also add the asterisks denoting that it's from the MA. I see that the apacite package has a function called \nocitemeta, but this doesn't seem to work here.

Is there a straightforward way to do this?


Solution

  • I know of two ways to achieve this, both only work with PDF documents (i.e., apa6_pdf()). Update: I have added a pandoc-citeproc approach below which I would recommend because it requires no new syntax and works for PDF and Word documents.

    1. apacite

    The first approach utilizes the apacite package and thereby enables the use of \nocitemeta. The downside to this approach is that, as far as I know, you need to deactivate pandoc-citeproc by setting pandoc: no. This causes the common pandoc-citeproc citation syntax (e.g., @R-papaja) to be ignored. You need to use the apacite syntax throughout your document.

    ---
    title             : "The title"
    shorttitle        : "Title"
    
    author: 
      - name          : "First Author"
        affiliation   : "1"
    
    affiliation:
      - id            : "1"
        institution   : "Wilhelm-Wundt-University"
    
    bibliography      : ["r-references.bib"]
    citeproc          : no
    
    header-includes   :
      - \usepackage[natbibapa]{apacite}
      - \bibliographystyle{apacite}
      - \renewcommand{\APACmetastar}{\ensuremath{{}^\ast}}
    
    documentclass     : "apa6"
    classoption       : "man"
    
    output            : papaja::apa6_pdf
    ---
    
    ```{r}
    library("papaja")
    ```
    
    \nocitemeta{R-base}
    
    This works: \citet{R-papaja}
    
    This doesn't work: @R-papaja
    
    ```{r create-r-references}
    r_refs(file = "r-references.bib")
    ```
    
    \bibliography{r-references.bib}
    

    2. biblatex

    The second approach, inspired by this answer, relies on biblatex and introduces a custom command that mimics \nocitemeta from apacite. The advantage here is that the pandoc-citeproc citation syntax still works.

    ---
    title             : "The title"
    shorttitle        : "Title"
    
    author: 
      - name          : "First Author"
        affiliation   : "1"
        corresponding : yes    # Define only one corresponding author
        address       : "Postal address"
        email         : "[email protected]"
    
    affiliation:
      - id            : "1"
        institution   : "Wilhelm-Wundt-University"
    
    bibliography      : ["r-references.bib"]
    biblio-style      : "apa"
    
    header-includes:
      - \DeclareLanguageMapping{english}{english-apa}
      - \DeclareBibliographyCategory{asterisk}
      - \renewbibmacro*{begentry}{\ifcategory{asterisk}{\ensuremath{{}^\ast}}{}}
      - \newcommand*{\nocitemeta}[1]{\nocite{#1}\addtocategory{asterisk}{#1}}
    
    output:
      papaja::apa6_pdf:
        citation_package: biblatex
    ---
    
    
    ```{r}
    library("papaja")
    ```
    
    \nocitemeta{R-base}
    
    Now this works: @R-papaja
    
    ```{r create-r-references}
    r_refs(file = "r-references.bib")
    ```
    
    \defbibnote{asterisk}{References marked with an asterisk indicate studies included in the meta-analysis.}
    \printbibliography[title=References,prenote=asterisk]
    \renewcommand{\printbibliography}{}
    

    3. pandoc-citeproc

    By modifying the default APA CSL file, it is possible to display an asterisk (or another indicator) in front of select bibliography entries.

    Update: papaja now supports this approach out of the box (see the manual). For the previous manual approach skip the following.

    To active bibliography annotation set annotate_references: yes

    ---
    title             : "The title"
    shorttitle        : "Title"
    
    author:
      - name          : "First Author"
        affiliation   : "1"
    
    bibliography      : ["r-references.bib"]
    annotate_references: yes
    nocite            : |
      @R-base
    
    output            : papaja::apa6_pdf
    ---
    
    ```{r}
    library("papaja")
    ```
    
    @R-papaja
    
    \newpage
    
    # References
    
    ```{r create_r-references}
    r_refs(file = "r-references.bib")
    ```
    
    \begingroup
    \setlength{\parindent}{-0.5in}
    \setlength{\leftskip}{0.5in}
    References marked with an asterisk indicate studies included in the meta-analysis.
    <div id = "refs"></div>
    \endgroup
    

    The edited BibTeX file r-references.bib looks like this (note the annotation field for R-base:

    @Manual{R-base,
      title = {R: A Language and Environment for Statistical Computing},
      author = {{R Core Team}},
      organization = {R Foundation for Statistical Computing},
      address = {Vienna, Austria},
      year = {2018},
      url = {https://www.R-project.org/},
      annote = {*}
    }
    @Manual{R-papaja,
      author = {Frederik Aust and Marius Barth},
      title = {{papaja}: {Create} {APA} manuscripts with {R Markdown}},
      year = {2018},
      note = {R package version 0.1.0.9842},
      url = {https://github.com/crsh/papaja},
    }
    

    Here's the old manual approach:

    Here, I chose the annotation field in the BibTeX file. I then use the nocite field in the YAML front matter to list the works included in the meta-analysis (additional entries need to be separated by ,).

    ---
    title             : "The title"
    shorttitle        : "Title"
    
    author:
      - name          : "First Author"
        affiliation   : "1"
    
    bibliography      : ["r-references.bib"]
    csl               : "apa6-meta.csl"
    nocite            : |
      @R-base
    
    output            : papaja::apa6_pdf
    ---
    
    ```{r}
    library("papaja")
    ```
    
    @R-papaja
    
    \newpage
    
    # References
    
    ```{r create_r-references}
    r_refs(file = "r-references.bib")
    ```
    
    \begingroup
    \setlength{\parindent}{-0.5in}
    \setlength{\leftskip}{0.5in}
    References marked with an asterisk indicate studies included in the meta-analysis.
    <div id = "refs"></div>
    \endgroup
    

    The edited BibTeX file r-references.bib looks like this (note the annotation field for R-base:

    @Manual{R-base,
      title = {R: A Language and Environment for Statistical Computing},
      author = {{R Core Team}},
      organization = {R Foundation for Statistical Computing},
      address = {Vienna, Austria},
      year = {2018},
      url = {https://www.R-project.org/},
      annotation = {meta-analysis}
    }
    @Manual{R-papaja,
      author = {Frederik Aust and Marius Barth},
      title = {{papaja}: {Create} {APA} manuscripts with {R Markdown}},
      year = {2018},
      note = {R package version 0.1.0.9842},
      url = {https://github.com/crsh/papaja},
    }