emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] tikz for multiple targets


From: Andreas Leha
Subject: Re: [O] tikz for multiple targets
Date: Tue, 16 Jul 2013 14:26:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi Eric,

Eric S Fraga <address@hidden> 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 via email to

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