From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Added possibility of overriding PGF inclusion command Date: Sat, 30 Jul 2016 21:57:12 +0200 Message-ID: <87wpk2dhlz.fsf@saiph.selenimh> References: <1468762532-44794-1-git-send-email-stefanos.carlstrom@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTaNn-0000B0-1D for emacs-orgmode@gnu.org; Sat, 30 Jul 2016 15:57:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTaNl-0001xU-V3 for emacs-orgmode@gnu.org; Sat, 30 Jul 2016 15:57:15 -0400 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:56729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTaNl-0001xI-P2 for emacs-orgmode@gnu.org; Sat, 30 Jul 2016 15:57:13 -0400 In-Reply-To: <1468762532-44794-1-git-send-email-stefanos.carlstrom@gmail.com> ("Stefanos \=\?utf-8\?Q\?Carlstr\=C3\=B6m\=22's\?\= message of "Sun, 17 Jul 2016 15:35:32 +0200") 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: Stefanos =?utf-8?Q?Carlstr=C3=B6m?= Cc: emacs-orgmode@gnu.org Hello, Stefanos Carlstr=C3=B6m writes: > * 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 Thank you for your patch. However, you can easily achieve the same using a filter, can't you? If a function needs to be introduced, it would be better to factor out the whole "tikz" and "pgf" handling, i.e., (progn (setq image-code (format "\\input{%s}" path)) (when (org-string-nw-p options) (setq image-code (format "\\begin{tikzpicture}[%s]\n%s\n\\end{tikzpicture}" options image-code))) (when (or (org-string-nw-p width) (org-string-nw-p height)) (setq image-code (format "\\resizebox{%s}{%s}{%s}" (if (org-string-nw-p width) width "!") (if (org-string-nw-p height) height "!") image-code)))) and have a variable holding a function to handle this such extensions, and doing the above as a default. Anyway, that's just an idea and people more knowledgeable on the subject may want to chime in. Regards, --=20 Nicolas Goaziou