From: Andreas Leha <andreas.leha@med.uni-goettingen.de>
To: Erik Iverson <eriki@ccbr.umn.edu>, emacs-orgmode@gnu.org
Subject: Re: [babel] Including TikZ diagrams as figures in export
Date: Mon, 21 Feb 2011 17:44:10 +0100 [thread overview]
Message-ID: <4D62965A.7020401@med.uni-goettingen.de> (raw)
In-Reply-To: <4D61C642.8060205@ccbr.umn.edu>
[-- Attachment #1.1.1: Type: text/plain, Size: 2730 bytes --]
Hi Jeffrey,
the attached sample file works for me.
The html is only sub-optimal, though, as it just includes a link to a
pdf file.
Cheers,
Andreas
Am 21.02.2011 02:56, schrieb Erik Iverson:
> Jeffrey,
>
>> Now, I'd like to integrate them into an org document. I'd like:
>> 1) To use babel to handle the TikZ source
>
> This is possible.
>
>> 2) To wrap the resulting drawing in a figure environment for
>> automatic numbering and centering
>
> See
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html
> and search for "tikz" for an example. I think you do need to use the
> :file argument
> for this to have org-mode take care of it automatically.
>
> Alternatively, you could just include *all* the latex you want, including
> constructing your own figure environment and caption and refs, in the
> latex
> code block.
>
>> 3) To be able to refer to the figure elsewhere in the document
>
> Should be possible with either approach above.
>
>> 4) (optional) To be able to seamlessly export to both LaTeX and HTML
>
> So should the HTML exporter generate a PNG file then, as opposed to PDF?
> This is possible, but requires some 'conditional' elisp code in your
> :file
> source block argument. I think I can help if that's indeed what you
> want.
>
>> And somewhat unrelated, is ":results" now deprecated in favor of
>> ":exports"? What about ":file"? I'm sufficiently new to babel that
>> these all seem like they could be taken care of with a single header
>> argument with many options...
>
> Not deprecated at all according to my understanding:
>
> :results determines how the results are collected from a process. So,
> in R, we
> might want the standard output ':results output' or we might just want
> the last
> value returned by the code block, ':results value'. This determines
> what is
> inserted into the org-mode buffer or the export stream when the code
> block
> is evaluated.
>
> :exports determines if the code and/or the results will be inserted upon
> exporting. *If* the results are inserted, then :results will determine
> how.
>
> :file is useful for code blocks that generate graphical output, such
> as tikz.
> This will divert the output into the named file, and exporting will
> insert
> that file. In the org-mode buffer, a link will be inserted. If a png
> file is
> generated, it can even be displayed inline in the org-mode buffer if
> you turn
> on that functionality.
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[-- Attachment #1.1.2: tikz_sample.org --]
[-- Type: text/plain, Size: 1083 bytes --]
#+LATEX_HEADER: \usepackage{tikz}
* Tikz Sample
In figure \ref{fig:tikz_sample} you can see something.
#+srcname: tikz_sample
#+begin_src latex :exports (if (eq backend 'latex) "none" "results") :file tikz_sample.pdf :headers '("\\usepackage{tikz}")
\usetikzlibrary{arrows}
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,thin,black}]
\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
\node [int, pin={[init]above:$v_0$}] (a) {$\frac{1}{s}$};
\node (b) [left of=a,node distance=2cm, coordinate] {a};
\node [int, pin={[init]above:$p_0$}] (c) [right of=a] {$\frac{1}{s}$};
\node [coordinate] (end) [right of=c, node distance=2cm]{};
\path[->] (b) edge node {$a$} (a);
\path[->] (a) edge node {$v$} (c);
\draw[->] (c) edge node {$p$} (end) ;
\end{tikzpicture}
#+end_src
#+begin_src latex :noweb yes
\begin{figure}
\centering
<<tikz_sample>>
\caption[Tikz]{Tikz}\label{fig:tikz_sample}
\end{figure}
#+end_src
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6432 bytes --]
[-- Attachment #2: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2011-02-21 16:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-20 23:03 [babel] Including TikZ diagrams as figures in export Jeffrey Horn
2011-02-21 1:56 ` Erik Iverson
2011-02-21 15:11 ` Jeff Horn
2011-02-21 16:57 ` Eric Schulte
2011-02-21 19:27 ` Jeff Horn
2011-02-21 16:44 ` Andreas Leha [this message]
2011-02-21 19:29 ` Jeff Horn
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=4D62965A.7020401@med.uni-goettingen.de \
--to=andreas.leha@med.uni-goettingen.de \
--cc=emacs-orgmode@gnu.org \
--cc=eriki@ccbr.umn.edu \
/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).