From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: How to use .pdf images on Latex export, and .png images on ODT export Date: Tue, 31 Jan 2017 09:00:04 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYbn5-0003Eu-KT for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 12:00:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYbn0-0006Pl-RS for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 12:00:23 -0500 Received: from iport-bcv3-out.ucsd.edu ([132.239.0.89]:39288) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYbn0-0006PM-EN for emacs-orgmode@gnu.org; Tue, 31 Jan 2017 12:00:18 -0500 In-Reply-To: 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: Giacomo M Cc: "emacs-orgmode@gnu.org" On Tue, 31 Jan 2017, Giacomo M wrote: > Dear all, > > I was wondering what is the best way to include pdf images on latex export > and png images on odt export (assuming same path, only extension changes). A > macro like this one: > #+MACRO: figext @@latex:.pdf@@@@odt:.png@@ > doesn't seem to work. No, it won't work as Babel runs before the exporter handles the snippets. Something like this should do. Run this block or put the code in your init file: #+BEGIN_SRC emacs-lisp (defun org-pdf-if-latex () (if (eq (org-bound-and-true-p org-export-current-backend) 'latex) "pdf" "png")) #+END_SRC This generates pdf for latex and png for all other backends (or no backend at all). #+name: pdf-or-png #+BEGIN_SRC R :exports both :results graphics :file-ext (org-pdf-if-latex) plot(rnorm(50)) #+END_SRC See (info "(org) file-ext") HTH, Chuck