{"id":13665969,"url":"https://github.com/crsh/citr","last_synced_at":"2025-04-05T08:09:06.770Z","repository":{"id":55326753,"uuid":"61821079","full_name":"crsh/citr","owner":"crsh","description":"RStudio Addin to Insert Markdown Citations from a BibTeX file or Zotero","archived":false,"fork":false,"pushed_at":"2023-11-20T10:20:58.000Z","size":4086,"stargazers_count":410,"open_issues_count":31,"forks_count":48,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T07:08:44.179Z","etag":null,"topics":["bib","bibliographies","insert-markdown-citations","rstudio-addin"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crsh.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-23T16:41:53.000Z","updated_at":"2025-03-22T08:14:13.000Z","dependencies_parsed_at":"2024-08-02T06:13:50.433Z","dependency_job_id":null,"html_url":"https://github.com/crsh/citr","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crsh%2Fcitr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crsh%2Fcitr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crsh%2Fcitr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crsh%2Fcitr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crsh","download_url":"https://codeload.github.com/crsh/citr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305935,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bib","bibliographies","insert-markdown-citations","rstudio-addin"],"created_at":"2024-08-02T06:00:54.916Z","updated_at":"2025-04-05T08:09:06.749Z","avatar_url":"https://github.com/crsh.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\ntitle   : \"citr: RStudio Addin to Insert Markdown Citations\"\noutput  : github_document\n---\n\n[![CRAN status](http://www.r-pkg.org/badges/version/citr)](https://cran.r-project.org/package=citr) [![Download counter](http://cranlogs.r-pkg.org/badges/citr)](https://cran.r-project.org/package=citr)\n[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![Build status](https://api.travis-ci.org/crsh/citr.svg?branch=master)](https://travis-ci.org/crsh/citr)\n\n`citr` provides functions and an [RStudio addin](https://rstudio.github.io/rstudioaddins/) to search a BibTeX-file to create and insert formatted Markdown citations into the current document.\n\n## Installation\n\nYou can either use the stable version of `citr` from CRAN,\n\n~~~r\ninstall.packages(\"citr\")\n~~~\n\nor the current development snapshot from this GitHub repository:\n\n~~~r\ndevtools::install_github(\"crsh/citr\")\n~~~\n\n\n## How to use citr\n\n### The RStudio addin\n\nOnce `citr` is installed and you have restarted your R session,  the addin appears in the menus.\nAlternatively, you can define a [keyboard shortcut](https://rstudio.github.io/rstudioaddins/#keyboard-shorcuts) to call the addin.\n\n![](tools/images/addin_demo.gif)\n\nThe addin will automatically look up the bibliography files specified in the YAML front matter.\nIf the document does not contain a YAML front matter the addin will attempt to locate a parent document and look up the bibliography file specified therein.\nThat is, the addin works its automagic even if you edit R Markdown documents that are included as [children](http://yihui.name/knitr/demo/child/) in another R Markdown document.\nThe expected names of a parent document default to `c(\"index.Rmd\", \"master.Rmd\")`, it thus works with [`bookdown`](https://bookdown.org/) out of the box, but can be customized (e.g., `options(citr.parent_documents = \"my_parent.Rmd\")`).\n\n\n### Using citr without RStudio\n\nThe following call searches a bibliography file and creates formatted Markdown citations for the results.\n\n~~~r\nlibrary(\"citr\")\nmd_cite(\"foo 2016\", bib_file = \"references.bib\")\n~~~\n\n`md_cite()` searches the author, year, title, and journal fields of your references.\n\n\n### Better BibTeX integration\nIf you are using Zotero `citr` can access your reference database directly.\nFor this to work, you need to install the [Better BibTeX extension](https://github.com/retorquere/zotero-better-bibtex/wiki).\nOnce the extension is installed and your reference manager is running, `citr` can access all your references and keep your bibliography file updated by adding missing references.\n\n![](tools/images/addin_zotero_demo.gif)\n\n\n### Tidying bibliography files\nWhen you are done writing, your bibliography file is likely to contain some unneeded references, which you added while writing but removed during revisions.\n`tidy_bib_file()` removes unneeded (or duplicate) entries from your bibliography file.\n\n~~~r\ntidy_bib_file(\n  rmd_file = \"report.Rmd\"\n  , messy_bibliography = \"references.bib\"\n  , file = \"tidy_references.bib\"\n)\n~~~\n\n## Known problems\n`citr` relies on `RefManager::ReadBib()` and, thus, indirectly on `bibtex::read.bib()` to load bibliographies.\nI have noticed that very long Bib(La)TeX fields can cause these underlying functions to fail (e.g., `Error in do_read_bib(file, encoding = .Encoding, srcfile): lex fatal error: input buffer overflow, can't enlarge buffer because scanner uses REJECT`).\nTo avoid such problems, I strongly recommend to disable the export of potentially long metadata fields, such as abstract and notes.\nThe Better BibTeX-plugin allows users to specify fields to omit:\n\n![](tools/images/bbt_omit_abstract.png)\n\nOnce, the above error has occurred, it may be necessary to restart the R session.\nOtherwise reading any other file may fail with `Error: lex fatal error: fatal flex scanner internal error--end of buffer missed`.\n\n\n## Other RStudio addins\n\nIf you are interested in other handy addins take a look at this [list](https://github.com/daattali/addinslist#readme). There you can find other useful addins, such as [rcrossref](https://github.com/ropensci/rcrossref) or [wordcountaddin](https://github.com/benmarwick/wordcountaddin).\n\n# Package dependencies\n\n```{r dependency_plot, echo = FALSE, fig.width = 7, fig.height = 5, message = FALSE, warning = FALSE, fig.path = \"tools/images/\"}\nsource(\"https://gist.githubusercontent.com/crsh/c906e93c260488e7363ea606243057c2/raw/f6f0fce38bc274446d205854ea35cfa03b9b1f7a/plot_dependencies.R\")\n\nplot_dependencies()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrsh%2Fcitr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrsh%2Fcitr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrsh%2Fcitr/lists"}