From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Stefanos=20Carlstr=C3=B6m?= Subject: [PATCH] Added possibility of overriding PGF inclusion command Date: Sun, 17 Jul 2016 15:35:32 +0200 Message-ID: <1468762532-44794-1-git-send-email-stefanos.carlstrom@gmail.com> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOmEQ-00021E-Q8 for emacs-orgmode@gnu.org; Sun, 17 Jul 2016 09:35:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bOmEK-00034B-PF for emacs-orgmode@gnu.org; Sun, 17 Jul 2016 09:35:41 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:32966) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bOmEK-00033n-Bf for emacs-orgmode@gnu.org; Sun, 17 Jul 2016 09:35:36 -0400 Received: by mail-wm0-x243.google.com with SMTP id o80so8843468wme.0 for ; Sun, 17 Jul 2016 06:35:35 -0700 (PDT) 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" To: emacs-orgmode@gnu.org Cc: =?UTF-8?q?Stefanos=20Carlstr=C3=B6m?= * ox-latex.el (org-latex--inline-image): The user can now customize the way PGF images are included by changing the (new) variable `org-latex-inline-pgf-command'. If the PGF file is stored in a subdirectory and references an external image file in the same directory, LaTeX will complain about not finding it. A workaround could be to define a function like this in the preamble: \newcommand\inputpgf[2]{{ \let\pgfimageWithoutPath\pgfimage \renewcommand{\pgfimage}[2][]{\pgfimageWithoutPath[##1]{#1/##2}} \input{#1/#2} }} and customizing `org-latex-inline-pgf-command' to hold this function: (lambda (path) (let ((dir-name (substring (file-name-directory path) 0 -1)) (file-name (file-name-nondirectory path))) (format "\\inputpgf{%s}{%s}" dir-name file-name))) This way, LaTeX will be able to find the external images. The idea came from here: http://tex.stackexchange.com/a/282110/9742 TINYCHANGE --- lisp/ox-latex.el | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 0901726..419f608 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -730,6 +730,19 @@ default we use here encompasses both." :type '(alist :key-type (string :tag "Type") :value-type (regexp :tag "Path"))) +(defcustom org-latex-inline-pgf-command + (lambda (path) (format "\\input{%s}" path)) + "Function used to include PGF images as links. By default, the +pgf images is included with a simple \input{file.pgf} command, +but the user might want to redefine this behaviour, if the pgf +file is stored in a subdirectory, and it references external +image files, as is the case when saving to PGF format from +matplotlib. The user can then specify a LaTeX command that takes +care of providing the correct search path for the external +dependencies, by redefining \pgfimage suitably." + :group 'org-export-latex + :type 'function) + (defcustom org-latex-link-with-unknown-path-format "\\texttt{%s}" "Format string for links with unknown path type." :group 'org-export-latex @@ -2300,12 +2313,12 @@ used as a communication channel." image-code) (if (member filetype '("tikz" "pgf")) ;; For tikz images: - ;; - use \input to read in image file. + ;; - use \input (default, can be overridden) to read in image file. ;; - if options are present, wrap in a tikzpicture environment. ;; - if width or height are present, use \resizebox to change ;; the image size. (progn - (setq image-code (format "\\input{%s}" path)) + (setq image-code (funcall org-latex-inline-pgf-command path)) (when (org-string-nw-p options) (setq image-code (format "\\begin{tikzpicture}[%s]\n%s\n\\end{tikzpicture}" -- 2.7.4 (Apple Git-66)