Cite author only in RMarkdown / add possessive 's to in-text citation

蹲街弑〆低调 提交于 2021-02-18 17:15:13

问题


I'd like to cite an author in RMarkdown adding a possessive 's to his name. However, I cannot find a way to cite the author without the year of publication or to directly add a possessive 's.

It should look like this:

In Fenner's (2012) book ...

Minimal Working Example (for a R Notebook):

---
title: "R Notebook"
output: html_notebook
references:
- id: fenner2012a
  title: One-click science marketing
  author:
  - family: Fenner
    given: Martin
  container-title: Nature Materials
  volume: 11
  URL: 'http://dx.doi.org/10.1038/nmat3283' 
  DOI: 10.1038/nmat3283
  issue: 4
  publisher: Nature Publishing Group
  page: 261-263
  type: article-journal
  issued:
    year: 2012
    month: 3
---

In @fenner2012a 's book ...

# References

Of course, I could add the name manually (In Fenner's [-@fenner2012a] book ...) but this is a sloppy workaround.

Is there another way?


回答1:


I don't know about RMarkdown, but in standard pandoc I've added the following filter directly after pandoc-citeproc.

#!/bin/bash

sed -s 's/\({"t":"Space"}\),\({"t":"Str","c":"(2013)"}]]}\),\({"t":"Str","c":"\x27s"}\)/\3,\1,\2/g'

It is horrible, and probably very delicate (and no good if you're on Windows), but it might put you on the right track.

Your citation would become "in @fenner2012a's book".



来源:https://stackoverflow.com/questions/44901308/cite-author-only-in-rmarkdown-add-possessive-s-to-in-text-citation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!