emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to use .pdf images on Latex export, and .png images on ODT e


From: Charles C. Berry
Subject: Re: [O] How to use .pdf images on Latex export, and .png images on ODT export
Date: Tue, 31 Jan 2017 09:00:04 -0800
User-agent: Alpine 2.20 (OSX 67 2015-01-07)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]