emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Embedding diagrams in Org


From: Andreas Leha
Subject: Re: [O] Embedding diagrams in Org
Date: Sat, 21 Feb 2015 11:06:47 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (darwin)

Hi,

Sebastien Vauban <address@hidden> writes:
> Hello Andreas,
>
> Andreas Leha wrote:
>> I also use tikz in my org files.  I just include a slightly more
>> involved version of Eric's example to show some of the beauty of org.
>>
>> This includes a caption for the diagram, and different output formats
>> for different export routes.
>>
>> #+LATEX_HEADER: \usepackage{tikz}
>>
>> * tikz example
>>
>> #+name: tikz_example
>> #+header: :packages '(("" "tikz"))
>> #+header: :file (by-backend (latex "example_diagram.tikz") (html 
>> "example_diagram.svg") (t "example_diagram.png"))
>
> Where is the `by-backend' function defined?
>

Sorry, I thought the by-backend function was 'common wisdom' by now.
It's been proposed by Eric Schulte and there has been a short discussion
about including it in org proper.  Here it is:

--8<---------------cut here---------------start------------->8---
(defmacro by-backend (&rest body)
  `(case (if (boundp 'backend) (org-export-backend-name backend) nil) ,@body))
--8<---------------cut here---------------end--------------->8---


And I forgot to add:  For the SVG export in html you might need to set

--8<---------------cut here---------------start------------->8---
(setq org-babel-latex-htlatex "htlatex")
--8<---------------cut here---------------end--------------->8---



>> #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 
>> 800
>> #+header: :results file raw
>> #+header: :fit yes
>> #+begin_src latex
>>   \begin{tikzpicture}
>>     \node[red!50!black] (a) {A};
>>     \node (b) [right of=a] {B};
>>     \draw[->] (a) -- (b);
>>   \end{tikzpicture}
>> #+end_src
>>
>> #+caption: A tikz example diagram with a caption
>> #+results: tikz_example
>> [[file:example_diagram.png]]
>
> What'd be nice is that you could say (in a *file* property) that the
> extension for LaTeX always has to be .tikz, for HTML .svg and .png in
> all the other cases.

I agree.  Especially if that setup should be applied to every figure in
the document, the header repetitions are tedious.  I do not have a
solution, I am afraid.

>
> Then, you could simply give the base name of the figure where
> appropriate, in a "DRY" configuration.

I'd love to see that, too.

Best,
Andreas




reply via email to

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