Function: org-cite-natbib-use-package

org-cite-natbib-use-package is a byte-compiled function defined in oc-natbib.el.gz.

Signature

(org-cite-natbib-use-package OUTPUT &rest _)

Documentation

Ensure output requires "natbib" package.

OUTPUT is the final output of the export process.

Source Code

;; Defined in /usr/src/emacs/lisp/org/oc-natbib.el.gz
(defun org-cite-natbib-use-package (output &rest _)
  "Ensure output requires \"natbib\" package.
OUTPUT is the final output of the export process."
  (with-temp-buffer
    (save-excursion (insert output))
    (when (search-forward "\\begin{document}" nil t)
      ;; Ensure there is a \usepackage{natbib} somewhere or add one.
      (goto-char (match-beginning 0))
      (let ((re (rx "\\usepackage" (opt "[" (*? nonl) "]") "{natbib}")))
        (unless (re-search-backward re nil t)
          (insert
           (format "\\usepackage%s{natbib}\n"
                   (if (null org-cite-natbib-options)
                       ""
                     (format "[%s]"
                             (mapconcat #'symbol-name
                                        org-cite-natbib-options
                                        ","))))))))
    (buffer-string)))