From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [PATCH 4/5] ox-latex: Treat tikz files as images Date: Wed, 20 Feb 2013 23:02:25 -0500 Message-ID: <1361419346-23146-5-git-send-email-aaronecay@gmail.com> References: <1361419346-23146-1-git-send-email-aaronecay@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:58080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8NMx-0001OO-IY for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8NMw-00038Q-An for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:51 -0500 Received: from mail-ve0-f181.google.com ([209.85.128.181]:58274) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8NMw-00038F-6X for emacs-orgmode@gnu.org; Wed, 20 Feb 2013 23:02:50 -0500 Received: by mail-ve0-f181.google.com with SMTP id d10so7661453vea.12 for ; Wed, 20 Feb 2013 20:02:49 -0800 (PST) In-Reply-To: <1361419346-23146-1-git-send-email-aaronecay@gmail.com> 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 Unlike other image types, they should be \input into the document – LaTeX converts the tikz source code into the image as part of the document’s compilation. --- lisp/ox-latex.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 100de1d..8027ce7 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -505,7 +505,7 @@ order to reproduce the default set-up: :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 @@ -1797,6 +1797,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)) @@ -1824,22 +1825,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