2016-03-30 08:44:30 +00:00
#+TITLE : BibTeX layer
2016-04-17 02:32:11 +00:00
2019-05-07 08:21:07 +00:00
#+TAGS : dsl|layer|markup|programming
2019-05-05 17:26:40 +00:00
2016-03-30 08:44:30 +00:00
[[file:img/logo.png ]]
2016-04-17 02:32:11 +00:00
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2018-01-09 21:38:12 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
- [[#configuration ][Configuration ]]
2021-08-25 19:31:18 +00:00
- [[#ebib-and-biblio ][Ebib and biblio ]]
2017-05-22 14:16:12 +00:00
- [[#key-bindings ][Key bindings ]]
2016-03-30 08:44:30 +00:00
* Description
2018-01-09 21:38:12 +00:00
BibTeX and BibLaTeX files are a common way to manage bibliographies. The format
2016-03-30 08:44:30 +00:00
was original designed to work with LaTeX files and subsequently has been adopted
by other markup formats such as MarkDown and Org mode.
2018-01-09 21:38:12 +00:00
This layer adds support to manipulate BibTeX and BibLaTeX files in Spacemacs.
2016-03-30 08:44:30 +00:00
2018-01-09 21:38:12 +00:00
** 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.
2021-08-25 19:31:18 +00:00
- Optionally install full fledged [[https://joostkremers.github.io/ebib/ebib-manual.html ][ebib reference manager ]]
2016-03-30 08:44:30 +00:00
* Install
2016-04-17 02:32:11 +00:00
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.
2016-03-30 08:44:30 +00:00
* Configuration
2018-01-09 21:38:12 +00:00
This layer also supports having a global BibTeX file. For a basic
2016-03-30 08:44:30 +00:00
configuration, add this to your =~/.spacemacs= inside
=dotspacemacs/user-config= :
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2016-03-30 08:44:30 +00:00
(setq org-ref-default-bibliography '("~/Papers/references.bib")
org-ref-pdf-directory "~/Papers/ "
org-ref-bibliography-notes "~/Papers/notes.org")
2018-09-19 03:54:47 +00:00
#+END_SRC
2016-03-30 08:44:30 +00:00
2016-04-17 02:32:11 +00:00
Certain modes, such as =latex-mode= with AucTeX, will automatically lookup
2016-03-30 08:44:30 +00:00
references in a document if any of the recognized bibliography commands are
2018-01-09 21:38:12 +00:00
used. Other modes may have a similar feature, or one could always set
2016-03-30 08:44:30 +00:00
file-local variables (through ~SPC f v f~ ).
2018-01-09 21:38:12 +00:00
You can also customize which program is used to display the PDFs. For example,
2016-03-30 08:44:30 +00:00
to use Zathura:
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC emacs-lisp
2016-04-17 02:32:11 +00:00
(setq org-ref-open-pdf-function
(lambda (fpath)
(start-process "zathura" "*helm-bibtex-zathura* " "/usr/bin/zathura" fpath)))
2018-09-19 03:54:47 +00:00
#+END_SRC
2016-03-30 08:44:30 +00:00
2018-09-15 21:36:37 +00:00
More configuration options are available and are detailed in the =org-ref= ,
2021-08-25 22:37:51 +00:00
=helm-bibtex= , =ivy-bibtex= and [[https://github.com/cpitclaudel/biblio.el ][biblio ]] package documentations.
2021-08-25 19:31:18 +00:00
** Ebib and biblio
2021-08-25 22:37:51 +00:00
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
2021-08-25 19:31:18 +00:00
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).
2016-03-30 08:44:30 +00:00
* Key bindings
2016-04-17 02:32:11 +00:00
In a Bib(La)TeX file, the following key bindings are added:
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2016-05-06 11:03:30 +00:00
|---------------------------+--------------------------------------------|
| ~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 |
2018-09-15 21:36:37 +00:00
| ~SPC m m~ | Manage bibtex library |
2019-05-26 20:58:52 +00:00
| ~SPC m l a~ | Lookup and add arXiv paper (don't get PDF) |
2016-05-06 11:03:30 +00:00
| ~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 |
2016-04-17 02:32:11 +00:00
In addition, =org-mode= , =latex-mode= and =markdown-mode= all have the following
2016-03-30 08:44:30 +00:00
key binding added:
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2016-03-30 08:44:30 +00:00
|-------------+-----------------|
| ~SPC m i c~ | Insert citation |
2021-08-25 19:31:18 +00:00
*EBIB*
*Index buffer*
2021-08-25 22:37:51 +00:00
| Key binding | Description |
2021-08-25 19:31:18 +00:00
|-------------+-------------------------------------------------------|
| ~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*
2021-08-25 22:37:51 +00:00
2021-08-25 19:31:18 +00:00
| ~q~ | quit entry buffer |
*Biblio selection buffer*
2021-08-25 22:37:51 +00:00
2021-08-25 19:31:18 +00:00
| ~e~ | import entry to current database (requires 'active' database in ebib index buffer) |
| ~C-j~ | Next entry |
| ~C-k~ | Previous entry |