#+TITLE: BibTeX layer #+TAGS: dsl|layer|markup|programming [[file:img/logo.png]] * Table of Contents :TOC_5_gh:noexport: - [[#description][Description]] - [[#features][Features:]] - [[#install][Install]] - [[#configuration][Configuration]] - [[#ebib-and-biblio][Ebib and biblio]] - [[#key-bindings][Key bindings]] * Description BibTeX and BibLaTeX files are a common way to manage bibliographies. The format was original designed to work with LaTeX files and subsequently has been adopted by other markup formats such as MarkDown and Org mode. This layer adds support to manipulate BibTeX and BibLaTeX files in Spacemacs. ** Features: - Syntax highlighting for BibTeX and BibLaTeX files. - Utilities for automatically adding entries from different data sources. - Support for inserting citations in various other modes. - Optionally install full fledged [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib reference manager]] * Install To use this configuration layer, add it to your =~/.spacemacs=. You will need to add =bibtex= to the existing =dotspacemacs-configuration-layers= list in this file. * Configuration This layer also supports having a global BibTeX file. For a basic configuration, add this to your =~/.spacemacs= inside =dotspacemacs/user-config=: #+BEGIN_SRC emacs-lisp (setq org-ref-default-bibliography '("~/Papers/references.bib") org-ref-pdf-directory "~/Papers/" org-ref-bibliography-notes "~/Papers/notes.org") #+END_SRC Certain modes, such as =latex-mode= with AucTeX, will automatically lookup references in a document if any of the recognized bibliography commands are used. Other modes may have a similar feature, or one could always set file-local variables (through ~SPC f v f~). You can also customize which program is used to display the PDFs. For example, to use Zathura: #+BEGIN_SRC emacs-lisp (setq org-ref-open-pdf-function (lambda (fpath) (start-process "zathura" "*helm-bibtex-zathura*" "/usr/bin/zathura" fpath))) #+END_SRC More configuration options are available and are detailed in the =org-ref=, =helm-bibtex=, =ivy-bibtex= and [[https://github.com/cpitclaudel/biblio.el][biblio]] package documentations. ** Ebib and biblio To enable installation of the [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib reference manager]] set the variable =bibtex-enable-ebib-support= as shown in the following code block: #+BEGIN_SRC emacs-lisp (bibtex :variables bibtex-enable-ebib-support t ebib-preload-bib-files '("path-to-bib-file.bib") ebib-file-search-dirs '("/path-to-documents-directory") ebib-import-directory "path-to-e.g.-download-directory") #+END_SRC The code block also shows how to set some optional [[https://joostkremers.github.io/ebib/ebib-manual.html][ebib]] variables. With the installation of the =ebib= package, Spacemacs automatically loads the [[https://joostkremers.github.io/ebib/ebib-manual.html#integration-with-the-biblio-package][ebib-biblio]] package that uses the [[https://github.com/cpitclaudel/biblio.el][biblio]] package to provide an easy way of fetching citations from the web into the database (follow the links to the packages additional descriptions and usage instructions). * Key bindings In a Bib(La)TeX file, the following key bindings are added: | Key binding | Description | |---------------------------+--------------------------------------------| | ~SPC m j~ / ~g j~ / ~C-j~ | Next entry | | ~SPC m k~ / ~g k~ / ~C-k~ | Previous entry | | ~SPC m p~ | Open PDF | | ~SPC m n~ | Open notes | | ~SPC m b~ | Open browser | | ~SPC m i~ | Insert new entry | | ~SPC m s~ | Sort entry | | ~SPC m h~ | Various actions on entry | | ~SPC m m~ | Manage bibtex library | | ~SPC m l a~ | Lookup and add arXiv paper (don't get PDF) | | ~SPC m l A~ | Lookup and add arXiv paper (download PDF) | | ~SPC m l d~ | Lookup and add paper by DOI | | ~SPC m l i~ | Lookup and add book by ISBN | | ~SPC m l p~ | Lookup and add paper by PMID | In addition, =org-mode=, =latex-mode= and =markdown-mode= all have the following key binding added: | Key binding | Description | |-------------+-----------------| | ~SPC m i c~ | Insert citation | *EBIB* *Index buffer* | Key binding | Description | |-------------+-------------------------------------------------------| | ~J/K~ | scroll page down/up | | ~g j~ | jump to entry (searches only author and title fields) | | ~SPC u g j~ | jump to entry (only) in current database | | ~/~ | ebib-search (searches in all fields) | | ~n~ | ebib-search-next | | ~e~ | switch to entry buffer | | ~SPC m k~ | delete current entry | | ~SPC m b~ | fetch current entry bibtex from web | | ~q~ | quit ebib | *Entry buffer* | ~q~ | quit entry buffer | *Biblio selection buffer* | ~e~ | import entry to current database (requires 'active' database in ebib index buffer) | | ~C-j~ | Next entry | | ~C-k~ | Previous entry |