emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Giacomo M <jackjackk@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
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	[thread overview]
Message-ID: <alpine.OSX.2.20.1701310849520.896@charles-berrys-macbook.local> (raw)
In-Reply-To: <b4133995-9948-a990-4c95-d6d877851fe1@gmail.com>

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	other threads:[~2017-01-31 17:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 14:16 How to use .pdf images on Latex export, and .png images on ODT export Giacomo M
2017-01-31 17:00 ` Charles C. Berry [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.20.1701310849520.896@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=jackjackk@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).