From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [PATCH] ob-R.el, ox-latex.el: support for tikz graphics Date: Sun, 24 Feb 2013 13:51:34 -0500 Message-ID: <1361731894-2738-1-git-send-email-aaronecay@gmail.com> Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9gfl-00070P-5r for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 13:51:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9gfj-0001Z4-2F for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 13:51:41 -0500 Received: from mail-qc0-f181.google.com ([209.85.216.181]:37243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9gfi-0001Ys-SV for emacs-orgmode@gnu.org; Sun, 24 Feb 2013 13:51:38 -0500 Received: by mail-qc0-f181.google.com with SMTP id a22so1017133qcs.12 for ; Sun, 24 Feb 2013 10:51:38 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Tikz graphics should be exported to LaTeX by \include, not as a link. This commit changes the file extension used for tikz graphics from .tex to .tikz. TINYCHANGE --- lisp/ob-R.el | 2 +- lisp/ox-latex.el | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lisp/ob-R.el b/lisp/ob-R.el index 8db0853..9875f81 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -237,7 +237,7 @@ current code buffer." '((:bmp . "bmp") (:jpg . "jpeg") (:jpeg . "jpeg") - (:tex . "tikz") + (:tikz . "tikz") (:tiff . "tiff") (:png . "png") (:svg . "svg") diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 0ac251f..13da3f0 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -482,7 +482,7 @@ which format headlines like for Org version prior to 8.0." :type 'string) (defcustom org-latex-inline-image-rules - '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\)\\'")) + '(("file" . "\\.\\(pdf\\|jpeg\\|jpg\\|png\\|ps\\|eps\\|tikz\\)\\'")) "Rules characterizing image files that can be inlined into LaTeX. A rule consists in an association whose key is the type of link @@ -1737,6 +1737,7 @@ used as a communication channel." (path (let ((raw-path (org-element-property :path link))) (if (not (file-name-absolute-p raw-path)) raw-path (expand-file-name raw-path)))) + (filetype (file-name-extension path)) (caption (org-latex--caption/label-string parent info)) ;; Retrieve latex attributes from the element around. (attr (org-export-read-attribute :attr_latex parent)) @@ -1764,22 +1765,25 @@ used as a communication channel." ((org-string-nw-p opt) (format "[%s]" opt)) ((eq float 'float) "[width=0.7\\textwidth]") ((eq float 'wrap) "[width=0.48\\textwidth]") - (t ""))))) + (t "")))) + (image-code (if (equal filetype "tikz") + (format "\\input{%s}" path) + (format "\\includegraphics%s{%s}" options path)))) ;; Return proper string, depending on FLOAT. (case float (wrap (format "\\begin{wrapfigure}%s \\centering -%s\\includegraphics%s{%s} -%s\\end{wrapfigure}" placement comment-include options path caption)) +%s%s +%s\\end{wrapfigure}" placement comment-include image-code caption)) (multicolumn (format "\\begin{figure*}%s \\centering -%s\\includegraphics%s{%s} -%s\\end{figure*}" placement comment-include options path caption)) +%s%s +%s\\end{figure*}" placement comment-include image-code caption)) (figure (format "\\begin{figure}%s \\centering -%s\\includegraphics%s{%s} -%s\\end{figure}" placement comment-include options path caption)) - (t (format "\\includegraphics%s{%s}" options path))))) +%s%s +%s\\end{figure}" placement comment-include image-code caption)) + (t image-code)))) (defun org-latex-link (link desc info) "Transcode a LINK object from Org to LaTeX. -- 1.8.1.4