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: tikz for multiple targets
Date: Tue, 16 Jul 2013 14:26:09 +0200	[thread overview]
Message-ID: <87mwpm3d3y.fsf@med.uni-goettingen.de> (raw)
In-Reply-To: 87vc4ahhbz.fsf@ucl.ac.uk

Hi Eric,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Hi Eric et al.,
>
> I now have a system I am happy with mostly for using LaTeX code blocks
> heading to multiple export targets.  The solution I am using is a
> combination of what has been discussed in this thread (by-backend
> customisation of headers for babel) and using noweb substitution for the
> main content.  I have two LaTeX babel source blocks, one for PDF export
> and the other for HTML export.  Each of these has a tikzpicture
> environment which then includes the actual instructions for drawing
> brought in using noweb.
>
> The problem I have remaining is how to get the version used to export to
> PDF via LaTeX to use a figure environment with captioning.  I had
> thought that something along these lines would work:
>
> #+begin_src org
>   ,#+name: picturecontents
>   ,#+begin_src latex :noweb yes :exports none
>     \node[red!50!black] (a) {A};
>     \node (b) [right of=a] {B};
>     \draw[->] (a) -- (b);
>   ,#+end_src
>   
>   ,#+name: flowdiagram
>   ,#+header: :exports (if (and (boundp 'backend) (eq (org-export-backend-name backend) (intern "latex"))) "results" "none")
>   ,#+header: :results latex
>   ,#+header: :noweb yes
>   ,#+begin_src latex
>     \begin{tikzpicture}
>       <<picturecontents>>
>     \end{tikzpicture}
>   ,#+end_src
>   
>   ,#+caption: Testing figure caption for figure going to multiple destinations
>   ,#+results: flowdiagram
> #+end_src
>
> as I expected the export to put the results of the flowdiagram code
> block after the results line.  This doesn't work: the exported LaTeX
> has no figure environment etc.  The diagram does come out but it is
> placed directly into the document.
>
> I hope this all makes sense?  Any suggestions?
>
> thanks,
> eric


I actually think, that it would be cool, if latex supported the tikz
output as R does.

But since you have a dedicated latex export-only block, the simplest
solution would be to put the caption inside:

--8<---------------cut here---------------start------------->8---
#+latex_header: \usepackage{tikz}
#+latex_header: \usepackage{hyperref}

* Test

#+name: picturecontents
#+begin_src latex :noweb yes :exports none
 \node[red!50!black] (a) {A};
 \node (b) [right of=a] {B};
 \draw[->] (a) -- (b);
#+end_src

#+name: flowdiagram
#+header: :exports (if (and (boundp 'backend) (eq (org-export-backend-name backend) (intern "latex"))) "results" "none")
#+header: :results latex
#+header: :noweb yes
#+begin_src latex
  \begin{figure}
   \begin{tikzpicture}
     <<picturecontents>>
   \end{tikzpicture}
   \caption{Testing figure caption for figure going to multiple destinations}
  \end{figure}
#+end_src
--8<---------------cut here---------------end--------------->8---


Regards,
Andreas

  reply	other threads:[~2013-07-16 12:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-09 22:34 tikz for multiple targets Eric S Fraga
2013-07-10  9:50 ` Rasmus
2013-07-10  9:54   ` Rasmus
2013-07-10 10:16     ` Fabrice Popineau
2013-07-10 10:56   ` Eric S Fraga
2013-07-10 20:44     ` Andreas Leha
2013-07-11  6:11       ` Eric Schulte
2013-07-11  8:38         ` Rasmus
2013-07-11 16:01           ` Eric Schulte
2013-07-11 10:50         ` Andreas Leha
2013-07-11 16:07           ` Eric Schulte
2013-07-11 18:56             ` Andreas Leha
2013-07-11 19:03               ` Eric Schulte
2013-07-11 23:15                 ` Andreas Leha
2013-07-11 22:33             ` Eric S Fraga
2013-07-12  0:20               ` Eric Schulte
2013-07-15 13:11                 ` Eric S Fraga
2013-07-16 11:31                 ` Eric S Fraga
2013-07-16 12:26                   ` Andreas Leha [this message]
2013-07-16 15:18                     ` Eric S Fraga
2013-07-11  7:21       ` Eric S Fraga
2013-07-11 15:58         ` Eric Schulte

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=87mwpm3d3y.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).