emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Using different image format given the export backend
@ 2013-07-01 19:02 Garrido Xavier
  2013-07-01 19:22 ` Vincent Beffara
  0 siblings, 1 reply; 3+ messages in thread
From: Garrido Xavier @ 2013-07-01 19:02 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Dear Orgers,

As explain is this forum thread 
http://stackoverflow.com/questions/13611837/how-can-i-use-different-image-formats-for-different-exports-in-org-mode, 
I'd also like to use different image format given the export backend. I 
have used the answer provided in the forum to have something like that

#+CAPTION: Toto figure
#+NAME: fig::toto
#+ATTR_LATEX: :width 0.38\textwidth
#+BEGIN_SRC emacs-lisp :exports results :results value raw
   (case (and (boundp 'backend) backend)
     (nil "")
     (latex "[[file:./toto.pdf]]"
     (html  "[[file:./toto.png]]"))
#+END_SRC

While the export is fine with html, when I export to latex->pdf, it 
gives me :

\includegraphics[width=.9\linewidth]{./toto.pdf}

not respecting the latex width attribute nor caption. I am using the new 
exporter and I wonder if I can get something working in the same way.

Thanks a lot for your help,
Xavier
-- 

   |
   |__     GARRIDO Xavier       Laboratoire de l'Accélérateur Linéaire
    /\     NEMO                 Université Paris-Sud 11
   /--\    garrido@lal.in2p3.fr UMR 8607
   |       garrido@in2p3.fr     Batiment 200
   |__     +33 1.64.46.84.28    91898 Orsay Cedex, France

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using different image format given the export backend
  2013-07-01 19:02 Using different image format given the export backend Garrido Xavier
@ 2013-07-01 19:22 ` Vincent Beffara
  2013-07-02  6:39   ` Xavier Garrido
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Beffara @ 2013-07-01 19:22 UTC (permalink / raw)
  To: emacs-orgmode


Hello,

> #+CAPTION: Toto figure
> #+NAME: fig::toto
> #+ATTR_LATEX: :width 0.38\textwidth
> #+BEGIN_SRC emacs-lisp :exports results :results value raw
>    (case (and (boundp 'backend) backend)
>      (nil "")
>      (latex "[[file:./toto.pdf]]"
>      (html  "[[file:./toto.png]]"))
> #+END_SRC

I do it like this:

(defun vb-massage-includegraphics (str backend opts)
  (replace-regexp-in-string ".png}" ".pdf}" str))
(add-hook 'org-export-filter-final-output-functions
          'vb-massage-includegraphics)

And then, simply refer to the png file in the .org file. Then nothing
happens for the html output, but on latex export, the regexp matches the
'}' and includes the .pdf file instead.

That is extremely ugly, and makes plenty of assumptions, most of all
that the .pdf file exists. And it should probably test for the value of
'backend'. But for personal use, it is convenient ...

           /v

-- 
Vincent Beffara

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Using different image format given the export backend
  2013-07-01 19:22 ` Vincent Beffara
@ 2013-07-02  6:39   ` Xavier Garrido
  0 siblings, 0 replies; 3+ messages in thread
From: Xavier Garrido @ 2013-07-02  6:39 UTC (permalink / raw)
  To: Vincent Beffara; +Cc: emacs-orgmode

Hi Vincent,

Thanks for the trick. Until I found something else I will try it ;)

Xavier

Le 01/07/2013 21:22, Vincent Beffara a écrit :
>
> Hello,
>
>> #+CAPTION: Toto figure
>> #+NAME: fig::toto
>> #+ATTR_LATEX: :width 0.38\textwidth
>> #+BEGIN_SRC emacs-lisp :exports results :results value raw
>>     (case (and (boundp 'backend) backend)
>>       (nil "")
>>       (latex "[[file:./toto.pdf]]"
>>       (html  "[[file:./toto.png]]"))
>> #+END_SRC
>
> I do it like this:
>
> (defun vb-massage-includegraphics (str backend opts)
>    (replace-regexp-in-string ".png}" ".pdf}" str))
> (add-hook 'org-export-filter-final-output-functions
>            'vb-massage-includegraphics)
>
> And then, simply refer to the png file in the .org file. Then nothing
> happens for the html output, but on latex export, the regexp matches the
> '}' and includes the .pdf file instead.
>
> That is extremely ugly, and makes plenty of assumptions, most of all
> that the .pdf file exists. And it should probably test for the value of
> 'backend'. But for personal use, it is convenient ...
>
>             /v
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-02  6:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-01 19:02 Using different image format given the export backend Garrido Xavier
2013-07-01 19:22 ` Vincent Beffara
2013-07-02  6:39   ` Xavier Garrido

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).