Hot answers tagged

19

Adding a line like the following is enough to tell org-mode which .bib file to consult: #+BIBLIOGRAPHY: refs plain refs is the name of the BibTeX file (.bib extension omitted), and plain is the bibliographystyle. You can then call org-reftex-citation (bound to C-c C-x [ by default) to insert references. From the documentation: (org-reftex-citation) ...


9

When the cursor is somewhere in the entry, run the command bibtex-fill-entry (bound to C-c C-q), which will align the fields. You may also want to set variable bibtex-align-at-equal-sign to a non nil value to change the details of alignment.


7

Never modify the source code in its original location like that. You'll lose (or be forced to merge) your changes whenever you upgrade. defcustom defines a "user option" variable. Variables are designed to be modified without touching the code, and for user options there's even a UI for that: M-x customize-option RET bibtex-generate-url-list RET Emacs will ...


6

reftex has the command reftex-create-bibtex-file that you can call via the menu Ref -> Global Actions -> Create BibTeX File. I cite the help of reftex-create-bibtex-file here: Create a new BibTeX database BIBFILE with all entries referenced in document. The command prompts for a filename and writes the collected entries to that file. Only ...


6

How about using keyboard macros: <f3> -- start recording C-M-s \b[A-Z]\{2,\}\b RET -- find the next word of only upper-case letters and at least 2 letters. M--M-c -- Call capitalize-word on the word before point M-0<f4> -- Stop recording and run the macro repeatedly until error n.b. If that's catching non-upper-case words as well, you'd need to set ...


5

(setq bibtex2html-program "/path/to/bibtex2html -nobibsource") Sorry for answering my own question.


4

The org-ref package contains this functionality. Contrary to the name, org-ref has a lot of functionality outside of org mode. Take a look at the function org-ref-format-bibtex-entry. It also integrates this into helm-bibtex, so if you get everything set up correctly, you can call helm-bibtex, mark the citations you want, then hit f7 which inserts a ...


4

Behold: (defun fancy-split (input) (let (tokens) (with-temp-buffer (insert input) (goto-char (point-min)) (while (not (eobp)) (cond ((looking-at "{") (forward-char) (let ((start (point))) (if (search-forward "}" nil t) (let ((token (buffer-substring start (1- (point)))))...


4

I think you need to put the local variables in two places, which is the org file and the bib file. The issue is that the notes functions are called while the bibtex buffer is active, so the local variables in the org file do not affect them. In my org file I put something like * File Local Variables # Local Variables: # org-ref-bibliography-notes: "/Users/...


4

It seems that ox-bibtex is not included in the latest org package (8.2.10-34-gc41bbc-elpa). So I searched it online and put into directory /org/lisp/ once downloaded. But I ran into the following error when trying to do an export involving some bibtex. Symbol's function definition is void: org-element-insert-before Then I check the file 'org-element.el',...


4

The order of the components of the key are hard-coded, so you can't change them with a user option. However, you can re-write the function to set the order you want. You need to load your modified function after the original version, so your modification will replace it. The following code does this: (eval-after-load "bibtex" '(defun bibtex-generate-...


3

reftex-using-biblatex-p is a simple function that finds whether the tex package biblatex is used by searching the text. The error may occur when the org file to be parsed is very large. So you can try a small file, or disable this function temporarily by (fset 'reftex-using-biblatex-p 'ignore), and see if reftex works.


3

This looks like a bug to me. You added the link to the master file to your file-local variables via C-c _, as you should. And as you note in the comments, this automatically inserted the mode: plain-tex line. This isn't what you want though, as the master file is in LaTeX mode. If you manually change your file-local variables to the following, it should work:...


3

For some reason, the file wasn't actually parsed, so AUCTeX didn't know about the bibliography file. This shouldn't usually happen if you set TeX-parse-self and TeX-auto-save to t, but you can easily trigger parsing with C-c C-n (TeX-normal-mode).


3

It's a bug in bibtex.el which only initializes some of its global vars after opening a file. Please M-x report-emacs-bug. While waiting for an actual fix, you can use the following workaround: add a call of the form (bibtex-set-dialect) some time after calling bibtex-mode.


2

In a similar approach to @giordano, I would suggest you have a look at the excellent Org-Ref, which is a collection of org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools; together with Helm-Bibtex, which can be used in unison with org-ref to search and manage your bibliographies. With your insert reference ...


2

Here's a basic function to look up the entry and title based on the citation at point (bibtex-completion is a dependency of org-ref): (defun my/print-reference-title () "Print the title to the reference at point in the minibuffer." (interactive) (message (assoc-default "title" (bibtex-completion-get-entry (org-...


2

Would the simple, if slightly barbaric, solution of setting bibtex-autokey-additional-names to "-etal", (with a hyphen built-in), work for you? It has the advantage that you don't have to source-dive or modify any of the elisp functions.


2

I had a similar issue, when using the smartparens package in bibtex-mode, where shameful amounts of spaces where inserted. For some reason unknown, bibtex-mode sets the fill-prefix variable to a string containing 18 spaces. (setq fill-prefix nil) in the bibtex-mode-hook fixed the issue in my case.


2

Here's something you could do using PEG parser. PEG parsers are a formalism allowing for generation of parsers without a tedious process like the one associated with YACC-style parsers. PEG-style parsers cannot capture some context-free languages, but due to easy augmentation with user code, they may often capture even some complex context-sensitive ...


2

Here's a recursive function that returns the name as a list of its components. (defun name-to-list (name &optional acc) "Takes a BibTeX-style name and returns a list of the name components." (if (string-equal name "") (nreverse (mapcar (lambda (part) (string-trim part "[ {]+" "[ }]+")) acc)) ...


2

This is something I've wanted too. I've implemented it for the timestamp as follows: First, we need a function to add the timestamp if it doesn't exist already. In my system I call the time stamp date_added, just swap that out for timestamp for your system: (defun bibty-add-date () "Adds a date_added field to a bibtex entry. Checks to make sure it doesn'...


2

You can add something like this to your init file to do that. (helm-add-action-to-source "Copy formatted citation(s)" (lambda (_) (kill-new (mapconcat 'identity (cl-loop for key in (helm-marked-candidates) collect (org-ref-format-entry key)) "\n\n"))) helm-...


2

To check if a field exists, one approach is: (defun bibtex-field-exists-p (field) (save-excursion (bibtex-beginning-of-entry) (let ((entry (bibtex-parse-entry))) (assoc field entry)))) If the field is missing, you could do something like: (unless (bibtex-field-exists-p "journal") (bibtex-make-field '("journal" nil "missing" nil)))


1

See the documentation of the configuration variable bibtex-completion-additional-search-fields. Example: (setq bibtex-completion-additional-search-fields '(keywords)) See also the documentation on GitHub.


1

Usually, you would use the align-regexp command (or the align command if bibtex-mode supported it). But that won't help you with the broken indentation.


1

If you want to take @phils answer and wrap it in a command that handles the region, here's one approach: (defun caps-to-title-case (start end) "Convert words in CAPS to Title Case in the current region or buffer." (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) ...


1

The order of the emacs call seems to be the problem. Should be emacs --batch -l emacs-load.el $< -f org-latex-export-to-pdf --kill Moreover, I needed to invoke the Makefile located in the org lisp directory hat I placed in my load-path. It work as expected with the above modifications.


1

I'm pretty sure the reason that's happening is because the org contributed libraries are not in your load-path. Ensure that directory is in your load path, and it should work. See Installation - The Org Manual if you don't already have it installed. If you already have it locally something like this should work: (add-to-list 'load-path "~/path/to/orgdir/...


1

I'm doing latex bibliography exports in Org9 with a regular bibtex file (literature.bib). At the location where I want the references to appear in the result, I put #+BIBLIOGRAPHY: /HOME/uidg1626/literature apalike into my org file or sub-header (for sub-tree export). Citing is done with org links e.g. [[cite:key_of_bibtex_entry]]. Before the above can ...


Only top voted, non community-wiki answers of a minimum length are eligible