oc-natbib: Provide a fallback bibliography style

* lisp/oc-natbib.el (org-cite-natbib-bibliography-style): New custom
option for default bibliography style.
(org-cite-natbib-export-bibliography): Use the new custom option.
* etc/ORG-NEWS (New ~org-cite-natbib-export-bibliography~ option
defining fallback bibliography style): Document the new option.

If we do not specify a bibliography style, LaTeX export will fail.
After the patch, the following simple-minded Org document will export
without errors:

 #+title: Testing org-cite \LaTeX export
 #+latex_header: \usepackage{natbib}
 #+bibliography: bibliography.bib
 #+options: toc:nil
 #+cite_export: natbib

 Hello World! This is a citation: [cite:@citationkey2023]

 #+print_bibliography:
This commit is contained in:
Ihor Radchenko 2023-01-25 18:02:49 +03:00
parent aa158da69b
commit d94f4066e0
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 26 additions and 5 deletions

View File

@ -24,6 +24,16 @@ consider [[https://gitlab.com/jackkamm/ob-python-mode-mode][ob-python-mode-mode]
has been ported to.
** New and changed options
*** New ~org-cite-natbib-export-bibliography~ option defining fallback bibliography style
~natbib~ citation export processor now uses
~org-cite-natbib-export-bibliography~ (defaults to ~unsrtnat~) as a
fallback bibliography style if none is specified by user in
=#+cite_export:= keyword.
Previously, export would fail without explicitly selected bibliography
style.
*** New escape in ~org-beamer-environments-extra~ for labels in Beamer export
The escape =%l= in ~org-beamer-environments-extra~ inserts the label
obtained from ~org-beamer--get-label~. This is added to the default

View File

@ -77,6 +77,15 @@ If \"natbib\" package is already required in the document, e.g., through
(const :tag "redefine \\thebibliography to issue \\section* instead of \\chapter*" sectionbib)
(const :tag "keep all the authors' names in a citation on one line" nonamebreak)))
(defcustom org-cite-natbib-bibliography-style 'unsrtnat
"Default bibliography style."
:group 'org-cite
:package-version '(Org . "9.7")
:type
'(choice
(const unsrtnat)
(symbol :tag "Other")))
;;; Internal functions
(defun org-cite-natbib--style-to-command (style)
@ -143,7 +152,9 @@ CITATION is the citation object. INFO is the export state, as a property list."
"Print references from bibliography FILES.
FILES is a list of absolute file names. STYLE is the bibliography style, as
a string or nil."
(concat (and style (format "\\bibliographystyle{%s}\n" style))
(concat
(format "\\bibliographystyle{%s}\n"
(or style org-cite-natbib-bibliography-style))
(format "\\bibliography{%s}"
(mapconcat #'file-name-sans-extension
files