emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: emacs-orgmode@gnu.org
Subject: Re: Embedding diagrams in Org
Date: Sat, 21 Feb 2015 11:06:47 +0000	[thread overview]
Message-ID: <olu1tljh6bc.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: 86pp96jngi.fsf@example.com

Hi,

Sebastien Vauban <sva-news@mygooglest.com> 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	other threads:[~2015-02-21 11:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18 12:34 Embedding diagrams in Org Marcin Borkowski
2015-02-18 14:19 ` Eric S Fraga
2015-02-18 15:51   ` Eduardo Ochs
2015-02-18 19:01     ` Eric S Fraga
2015-02-19  8:45       ` Sebastien Vauban
2015-02-18 19:37   ` Andreas Leha
2015-02-19  8:49     ` Sebastien Vauban
2015-02-21 11:06       ` Andreas Leha [this message]
2015-02-19 14:10     ` Eric S Fraga
2015-03-21 11:23     ` Marcin Borkowski
2015-03-21 21:41       ` Andreas Leha
2015-02-24  0:01   ` Marcin Borkowski
2015-02-24  8:04     ` Eric S Fraga
2015-02-24 17:00       ` Charles C. Berry
2015-03-05  8:51         ` Sebastien Vauban
2015-03-04 19:19 ` Marcin Borkowski
2015-03-04 19:37   ` Rasmus
2015-03-04 21:22   ` Andreas Leha
2015-03-05  8:12     ` Eric S Fraga

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=olu1tljh6bc.fsf@med.uni-goettingen.de \
    --to=andreas.leha@med.uni-goettingen.de \
    --cc=emacs-orgmode@gnu.org \
    /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).