emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-R.el, ox-latex.el: support for tikz graphics
@ 2013-02-24 18:51 Aaron Ecay
  2013-02-25 15:19 ` Nicolas Goaziou
  2013-02-26 18:25 ` [PATCH] ob-R.el, ox-latex.el: support for tikz graphics Achim Gratz
  0 siblings, 2 replies; 17+ messages in thread
From: Aaron Ecay @ 2013-02-24 18:51 UTC (permalink / raw)
  To: emacs-orgmode

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

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

end of thread, other threads:[~2013-03-06  8:36 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-24 18:51 [PATCH] ob-R.el, ox-latex.el: support for tikz graphics Aaron Ecay
2013-02-25 15:19 ` Nicolas Goaziou
2013-02-26 10:50   ` Achim Gratz
2013-02-26 12:25     ` Myles English
2013-02-26 13:21     ` Nicolas Goaziou
2013-02-26 14:33       ` Achim Gratz
2013-02-26 19:21       ` Aaron Ecay
2013-02-26 19:22         ` [PATCH] ox-latex: provide width and height options for images Aaron Ecay
2013-02-26 23:04           ` Rasmus
2013-02-27  2:02             ` Aaron Ecay
2013-02-27 18:40             ` Achim Gratz
2013-02-27  8:23           ` Nicolas Goaziou
2013-03-06  4:02             ` aaronecay
2013-03-06  4:04               ` [PATCH] ox-latex: Support tikz images, :width, and :height Aaron Ecay
2013-03-06  8:35               ` [PATCH] ox-latex: provide width and height options for images Nicolas Goaziou
2013-02-26 18:25 ` [PATCH] ob-R.el, ox-latex.el: support for tikz graphics Achim Gratz
2013-02-26 19:49   ` Aaron Ecay

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).