emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add "latex" option to ox-bibtex.el
@ 2013-07-12  7:26 feng shu
  2013-07-12 10:36 ` Nicolas Goaziou
  0 siblings, 1 reply; 7+ messages in thread
From: feng shu @ 2013-07-12  7:26 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org


[-- Attachment #1.1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #1.2: Type: text/html, Size: 26 bytes --]

[-- Attachment #2: 0001-Add-latex-optional-option-to-ox-bibtex.patch --]
[-- Type: application/octet-stream, Size: 3393 bytes --]

From 34d1af7f1b0ecb38000f7a19ad17f3d7bfdf26fa Mon Sep 17 00:00:00 2001
From: Feng Shu <tumashu@gmail.com>
Date: Fri, 12 Jul 2013 15:14:56 +0800
Subject: [PATCH] Add "latex" optional option to ox-bibtex

* ox-bibtex.el (org-latex-keyword, org-bibtex-get-arguments):
Add `:latex' properties.

If "latex" option is set to `nil', when export to latex,
"ox-bibtex"  will not insert bibliography commands in output file.
you should insert the commands manually, for example:

\#+BIBLIOGRAPHY: foo plain option:-d latex:nil
\bibliographystyle{otherbibstyle}
\bibliography{foo}

or:

\#+BIBLIOGRAPHY: foo plain option:-d latex:nil
\printbibliography
---
 contrib/lisp/ox-bibtex.el |   21 +++++++++++++++------
 1 个文件被修改,插入 15 行(+),删除 6 行(-)

diff --git a/contrib/lisp/ox-bibtex.el b/contrib/lisp/ox-bibtex.el
index 29a97eb..3e0b3a4 100644
--- a/contrib/lisp/ox-bibtex.el
+++ b/contrib/lisp/ox-bibtex.el
@@ -63,6 +63,12 @@
 ;;   \bibliographystyle{plain}
 ;;   \bibliography{foo}
 ;;
+;; If you prefer to use different latex command for LaTeX export,
+;; For example: \printbibliography, you can use "latex" option:
+;;
+;;   #+BIBLIOGRAPHY: foo plain option:-d latex:nil
+;;   \printbibliography
+;;
 ;; into the TeX file when exporting.
 ;;
 ;; For HTML export it:
@@ -103,21 +109,23 @@ return nil instead."
 (defun org-bibtex-get-arguments (keyword)
   "Return \"bibtex2html\" arguments specified by the user.
 KEYWORD is a \"BIBLIOGRAPHY\" keyword. Return value is a plist
-containing `:options' and `:limit' properties. The former
+containing `:options' `:limit' and `latex'  properties. The first one
 contains a list of strings to be passed as options ot
-\"bibtex2html\" process. The latter contains a boolean."
+\"bibtex2html\" process. The rest contains a boolean."
   (let ((value (org-element-property :value keyword)))
     (and value
          (string-match "\\(\\S-+\\)[ \t]+\\(\\S-+\\)\\(.*\\)" value)
-         (let (options limit)
+         (let (options limit latex)
            (dolist (arg (org-split-string (match-string 3 value))
                         ;; Return value.
-                        (list :options (nreverse options) :limit limit))
+                        (list :options (nreverse options) :limit limit :latex latex))
              (let* ((s (split-string arg ":"))
                     (key (car s))
                     (value (nth 1 s)))
                (cond ((equal "limit" key)
                       (setq limit (not (equal "nil" value))))
+		     ((equal "latex" key)
+                      (setq latex (not (equal "nil" value))))
                      ((equal "option" key) (push value options)))))))))
 
 (defun org-bibtex-citation-p (object)
@@ -148,9 +156,10 @@ Fallback to `latex' back-end for other keywords."
     (if (not (equal (org-element-property :key keyword) "BIBLIOGRAPHY"))
         ad-do-it
       (let ((file (org-bibtex-get-file keyword))
-            (style (org-bibtex-get-style keyword)))
+            (style (org-bibtex-get-style keyword))
+	    (ox-bibtex-export-latex-p (plist-get (org-bibtex-get-arguments keyword) :latex)))
         (setq ad-return-value
-              (when file
+              (when (and file ox-bibtex-export-latex-p)
                 (concat (and style (format "\\bibliographystyle{%s}\n" style))
                         (format "\\bibliography{%s}" file))))))))
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-07-13 11:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12  7:26 [PATCH] Add "latex" option to ox-bibtex.el feng shu
2013-07-12 10:36 ` Nicolas Goaziou
2013-07-12 13:17   ` feng shu
2013-07-12 13:36     ` Nicolas Goaziou
2013-07-12 23:15       ` feng shu
2013-07-13  8:41         ` Nicolas Goaziou
2013-07-13 11:36           ` Feng Shu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).