emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] create tikz pictures in an floating LaTeX environment
@ 2011-10-07 14:02 Torsten Wagner
  2011-10-07 14:13 ` Nick Dokos
  0 siblings, 1 reply; 10+ messages in thread
From: Torsten Wagner @ 2011-10-07 14:02 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi all,
Hi Eric (hehehe because most likely you read it ;) )

I try for the first time to write an entire article in org-mode.
I do so, because with the tags :export: :noexport: I can easily keep
my personal notes and todos "hidden" and the final export will be just
what I want to publish.
Furthermore, I'm interested to do my data evaluation in python blocks
within the org-file itself, keeping all nicely together.

At the moment I try to add a tikz picture to the manuscript. I
followed the example at
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html
However, I have some problems. I can generate the picture by using the
following code.

#+srcname: mypicture
#+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
:border 1em :fit
  \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
      \draw[fill=red!50] (0,0) rectangle  ++(5,1);
      \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
      \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
      \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
      \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
  \end{scope}
  \end{tikzpicture}
#+end_src

Now, I want to include this in a floating figure environment
This troubles me a bit.
I tried to make a second latex src block which includes the
environment and an \includegraphic pointing to the generated pdf file.
However, I always find a link of the filename in addtion. I guess this
is the result of the first (above) source code block. The pdf contains
a line similar like
[[file:fig/mypicture.pdf ]]

I switched over to use the org-mode way of including a figure and
replaced the latex second src code block by

#+CAPTION:    my great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
[[file:fig/mypicture.pdf]]

This worked out too and was identically to the fist approach, however,
there was still the result line in the output.
I tried to add exports: none  and volia the line was gone. However,
the source code block was not exported at all and hence the picture
not updated at all (it simply used the old generated pdf)

I tried to be ueber-smart and replaced the static link
[[file:fig/mypicture.pdf]]
by
#+call:  mypicture
in the hope it would be executed and result in
[[file:fig/mypicture.pdf]]
finally getting the same like with the static link. However, this did
not work out at all. No figure.

Could someone help me to sort this out. Ideally, I would like to do a
rather logical combination and end up with the following:

#+CAPTION:    my great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
#+srcname: mypicture
#+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
:border 1em :fit
  \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
      \draw[fill=red!50] (0,0) rectangle  ++(5,1);
      \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
      \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
      \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
      \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
  \end{scope}
  \end{tikzpicture}
#+end_src

avoiding to call/type  the filename/link over and over again.

Thanks for helping

Torsten

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 14:02 [babel] create tikz pictures in an floating LaTeX environment Torsten Wagner
@ 2011-10-07 14:13 ` Nick Dokos
  2011-10-07 15:14   ` Eric Schulte
  2011-10-08 14:29   ` Torsten Wagner
  0 siblings, 2 replies; 10+ messages in thread
From: Nick Dokos @ 2011-10-07 14:13 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: nicholas.dokos, Org Mode Mailing List

Torsten Wagner <torsten.wagner@gmail.com> wrote:

> Hi all,
> Hi Eric (hehehe because most likely you read it ;) )
> 
> I try for the first time to write an entire article in org-mode.
> I do so, because with the tags :export: :noexport: I can easily keep
> my personal notes and todos "hidden" and the final export will be just
> what I want to publish.
> Furthermore, I'm interested to do my data evaluation in python blocks
> within the org-file itself, keeping all nicely together.
> 
> At the moment I try to add a tikz picture to the manuscript. I
> followed the example at
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html
> However, I have some problems. I can generate the picture by using the
> following code.
> 
> #+srcname: mypicture
> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
> :border 1em :fit
>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
>   \end{scope}
>   \end{tikzpicture}
> #+end_src
> 
> Now, I want to include this in a floating figure environment
> This troubles me a bit.
> I tried to make a second latex src block which includes the
> environment and an \includegraphic pointing to the generated pdf file.
> However, I always find a link of the filename in addtion. I guess this
> is the result of the first (above) source code block. The pdf contains
> a line similar like
> [[file:fig/mypicture.pdf ]]
> 


``:results output silent'' should suppress that I think.

Nick

> I switched over to use the org-mode way of including a figure and
> replaced the latex second src code block by
> 
> #+CAPTION:    my great picture
> #+LABEL:      fig:my_picture
> #+ATTR_LaTeX:
> [[file:fig/mypicture.pdf]]
> 
> This worked out too and was identically to the fist approach, however,
> there was still the result line in the output.
> I tried to add exports: none  and volia the line was gone. However,
> the source code block was not exported at all and hence the picture
> not updated at all (it simply used the old generated pdf)
> 
> I tried to be ueber-smart and replaced the static link
> [[file:fig/mypicture.pdf]]
> by
> #+call:  mypicture
> in the hope it would be executed and result in
> [[file:fig/mypicture.pdf]]
> finally getting the same like with the static link. However, this did
> not work out at all. No figure.
> 
> Could someone help me to sort this out. Ideally, I would like to do a
> rather logical combination and end up with the following:
> 
> #+CAPTION:    my great picture
> #+LABEL:      fig:my_picture
> #+ATTR_LaTeX:
> #+srcname: mypicture
> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
> :border 1em :fit
>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
>   \end{scope}
>   \end{tikzpicture}
> #+end_src
> 
> avoiding to call/type  the filename/link over and over again.
> 
> Thanks for helping
> 
> Torsten
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 14:13 ` Nick Dokos
@ 2011-10-07 15:14   ` Eric Schulte
  2011-10-07 21:26     ` Darlan Cavalcante Moreira
  2011-10-08 14:45     ` Torsten Wagner
  2011-10-08 14:29   ` Torsten Wagner
  1 sibling, 2 replies; 10+ messages in thread
From: Eric Schulte @ 2011-10-07 15:14 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Org Mode Mailing List

Nick Dokos <nicholas.dokos@hp.com> writes:

> Torsten Wagner <torsten.wagner@gmail.com> wrote:
>
>> Hi all,
>> Hi Eric (hehehe because most likely you read it ;) )
>> 
>> I try for the first time to write an entire article in org-mode.
>> I do so, because with the tags :export: :noexport: I can easily keep
>> my personal notes and todos "hidden" and the final export will be just
>> what I want to publish.
>> Furthermore, I'm interested to do my data evaluation in python blocks
>> within the org-file itself, keeping all nicely together.
>> 
>> At the moment I try to add a tikz picture to the manuscript. I
>> followed the example at
>> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html
>> However, I have some problems. I can generate the picture by using the
>> following code.
>> 
>> #+srcname: mypicture
>> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
>> :border 1em :fit
>>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
>>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
>>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
>>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
>>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
>>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
>>   \end{scope}
>>   \end{tikzpicture}
>> #+end_src
>> 
>> Now, I want to include this in a floating figure environment
>> This troubles me a bit.
>> I tried to make a second latex src block which includes the
>> environment and an \includegraphic pointing to the generated pdf file.
>> However, I always find a link of the filename in addtion. I guess this
>> is the result of the first (above) source code block. The pdf contains
>> a line similar like
>> [[file:fig/mypicture.pdf ]]
>> 
>
>
> ``:results output silent'' should suppress that I think.
>

Nick's solution should work well.  Also, (if you're exporting to LaTeX)
couldn't you just combine the tikz picture and the wrapping figure
environment into a single begin_latex block?

Best -- Eric

>
> Nick
>
>> I switched over to use the org-mode way of including a figure and
>> replaced the latex second src code block by
>> 
>> #+CAPTION:    my great picture
>> #+LABEL:      fig:my_picture
>> #+ATTR_LaTeX:
>> [[file:fig/mypicture.pdf]]
>> 
>> This worked out too and was identically to the fist approach, however,
>> there was still the result line in the output.
>> I tried to add exports: none  and volia the line was gone. However,
>> the source code block was not exported at all and hence the picture
>> not updated at all (it simply used the old generated pdf)
>> 
>> I tried to be ueber-smart and replaced the static link
>> [[file:fig/mypicture.pdf]]
>> by
>> #+call:  mypicture
>> in the hope it would be executed and result in
>> [[file:fig/mypicture.pdf]]
>> finally getting the same like with the static link. However, this did
>> not work out at all. No figure.
>> 
>> Could someone help me to sort this out. Ideally, I would like to do a
>> rather logical combination and end up with the following:
>> 
>> #+CAPTION:    my great picture
>> #+LABEL:      fig:my_picture
>> #+ATTR_LaTeX:
>> #+srcname: mypicture
>> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
>> :border 1em :fit
>>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
>>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
>>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
>>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
>>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
>>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
>>   \end{scope}
>>   \end{tikzpicture}
>> #+end_src
>> 
>> avoiding to call/type  the filename/link over and over again.
>> 
>> Thanks for helping
>> 
>> Torsten
>> 
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 15:14   ` Eric Schulte
@ 2011-10-07 21:26     ` Darlan Cavalcante Moreira
  2011-10-07 21:44       ` Tom Prince
  2011-10-08  6:32       ` Achim Gratz
  2011-10-08 14:45     ` Torsten Wagner
  1 sibling, 2 replies; 10+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-10-07 21:26 UTC (permalink / raw)
  To: Eric Schulte; +Cc: nicholas.dokos, Org Mode Mailing List


I have a (very) small personal wiki in org mode where I add stuff that I
read/learn that deserve this work. I usually don't need to export it, but
recently I was trying to export it to PDF and HTML and I had the same doubt
with a block o tikz code.

It would be nice if org had a begin_tikz block. This block could either
create a PDF file or include the tikz code directly in the latex file when
exporting to latex (or PDF), and create an SVG file when when exporting to
HTML. Of course this block should accept all the usual image options, such
as caption and width.

This is just a feature request from a tikz lover.

--
Darlan

At Fri, 07 Oct 2011 09:14:20 -0600,
Eric Schulte wrote:
> 
> Nick Dokos <nicholas.dokos@hp.com> writes:
> 
> > Torsten Wagner <torsten.wagner@gmail.com> wrote:
> >
> >> Hi all,
> >> Hi Eric (hehehe because most likely you read it ;) )
> >> 
> >> I try for the first time to write an entire article in org-mode.
> >> I do so, because with the tags :export: :noexport: I can easily keep
> >> my personal notes and todos "hidden" and the final export will be just
> >> what I want to publish.
> >> Furthermore, I'm interested to do my data evaluation in python blocks
> >> within the org-file itself, keeping all nicely together.
> >> 
> >> At the moment I try to add a tikz picture to the manuscript. I
> >> followed the example at
> >> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-LaTeX.html
> >> However, I have some problems. I can generate the picture by using the
> >> following code.
> >> 
> >> #+srcname: mypicture
> >> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
> >> :border 1em :fit
> >>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
> >>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
> >>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
> >>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
> >>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
> >>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
> >>   \end{scope}
> >>   \end{tikzpicture}
> >> #+end_src
> >> 
> >> Now, I want to include this in a floating figure environment
> >> This troubles me a bit.
> >> I tried to make a second latex src block which includes the
> >> environment and an \includegraphic pointing to the generated pdf file.
> >> However, I always find a link of the filename in addtion. I guess this
> >> is the result of the first (above) source code block. The pdf contains
> >> a line similar like
> >> [[file:fig/mypicture.pdf ]]
> >> 
> >
> >
> > ``:results output silent'' should suppress that I think.
> >
> 
> Nick's solution should work well.  Also, (if you're exporting to LaTeX)
> couldn't you just combine the tikz picture and the wrapping figure
> environment into a single begin_latex block?
> 
> Best -- Eric
> 
> >
> > Nick
> >
> >> I switched over to use the org-mode way of including a figure and
> >> replaced the latex second src code block by
> >> 
> >> #+CAPTION:    my great picture
> >> #+LABEL:      fig:my_picture
> >> #+ATTR_LaTeX:
> >> [[file:fig/mypicture.pdf]]
> >> 
> >> This worked out too and was identically to the fist approach, however,
> >> there was still the result line in the output.
> >> I tried to add exports: none  and volia the line was gone. However,
> >> the source code block was not exported at all and hence the picture
> >> not updated at all (it simply used the old generated pdf)
> >> 
> >> I tried to be ueber-smart and replaced the static link
> >> [[file:fig/mypicture.pdf]]
> >> by
> >> #+call:  mypicture
> >> in the hope it would be executed and result in
> >> [[file:fig/mypicture.pdf]]
> >> finally getting the same like with the static link. However, this did
> >> not work out at all. No figure.
> >> 
> >> Could someone help me to sort this out. Ideally, I would like to do a
> >> rather logical combination and end up with the following:
> >> 
> >> #+CAPTION:    my great picture
> >> #+LABEL:      fig:my_picture
> >> #+ATTR_LaTeX:
> >> #+srcname: mypicture
> >> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
> >> :border 1em :fit
> >>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
> >>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
> >>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
> >>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
> >>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
> >>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
> >>   \end{scope}
> >>   \end{tikzpicture}
> >> #+end_src
> >> 
> >> avoiding to call/type  the filename/link over and over again.
> >> 
> >> Thanks for helping
> >> 
> >> Torsten
> >> 
> >
> 
> -- 
> Eric Schulte
> http://cs.unm.edu/~eschulte/
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 21:26     ` Darlan Cavalcante Moreira
@ 2011-10-07 21:44       ` Tom Prince
  2011-10-08  6:32       ` Achim Gratz
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Prince @ 2011-10-07 21:44 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira, Eric Schulte
  Cc: nicholas.dokos, Org Mode Mailing List

On Fri, 07 Oct 2011 18:26:15 -0300, Darlan Cavalcante Moreira <darcamo@gmail.com> wrote:
> It would be nice if org had a begin_tikz block. This block could either
> create a PDF file or include the tikz code directly in the latex file when
> exporting to latex (or PDF), and create an SVG file when when exporting to
> HTML. Of course this block should accept all the usual image options, such
> as caption and width.
> 
> This is just a feature request from a tikz lover.

This would actually be useful for arbitrary latex code. I know in
particular that I would love a similiar feature for using Paul Taylor's
diagram.sty[fn:1], generetating inline latex, when compiling to PDF, and
genertating an SVG when exporting to HTML.

It would also be very nice not to have to name every block, just like
the inline math doesn't need to be given a name, when using one of the
image backends.

  Tom

Footnotes:

[fn:1] http://www.paultaylor.eu/diagrams/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 21:26     ` Darlan Cavalcante Moreira
  2011-10-07 21:44       ` Tom Prince
@ 2011-10-08  6:32       ` Achim Gratz
  1 sibling, 0 replies; 10+ messages in thread
From: Achim Gratz @ 2011-10-08  6:32 UTC (permalink / raw)
  To: emacs-orgmode

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:
> It would be nice if org had a begin_tikz block. This block could either
> create a PDF file or include the tikz code directly in the latex file when
> exporting to latex (or PDF), and create an SVG file when when exporting to
> HTML. Of course this block should accept all the usual image options, such
> as caption and width.

A simple search for "org LaTeX block" would get you to this Worg
tutorial:

http://orgmode.org/worg/org-tutorials/org-latex-export.html

where you will find an intro to the contributed org-special-blocks.el,
which almost does what you want already.  I don't think it takes option
arguments, but you can always define a new environment in your LaTeX
setup that is already set up correctly.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 14:13 ` Nick Dokos
  2011-10-07 15:14   ` Eric Schulte
@ 2011-10-08 14:29   ` Torsten Wagner
  1 sibling, 0 replies; 10+ messages in thread
From: Torsten Wagner @ 2011-10-08 14:29 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Org Mode Mailing List

Hi Nicholas,

>> a line similar like
>> [[file:fig/mypicture.pdf ]]
>>
>
>
> ``:results output silent'' should suppress that I think.
>

Yep, thanks that did the job.
Nevertheless, I have to add the generated output as a static link to
add resp. export it in an org-mode way..
#+CAPTION:   My great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
[[fig/mpicture.pdf]]

Replacing the manual link by the function call
#+call: mypicture()
only results again in the line
fig/mypicture.pdf (this time without square brackets)

Thanks a lot for the help

Torsten

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-07 15:14   ` Eric Schulte
  2011-10-07 21:26     ` Darlan Cavalcante Moreira
@ 2011-10-08 14:45     ` Torsten Wagner
  2011-10-08 19:49       ` Eric Schulte
  2011-10-09  7:30       ` Christian Moe
  1 sibling, 2 replies; 10+ messages in thread
From: Torsten Wagner @ 2011-10-08 14:45 UTC (permalink / raw)
  To: Eric Schulte; +Cc: nicholas.dokos, Org Mode Mailing List

Hi Eric

>>
>> ``:results output silent'' should suppress that I think.
>>
>
> Nick's solution should work well.  Also, (if you're exporting to LaTeX)
> couldn't you just combine the tikz picture and the wrapping figure
> environment into a single begin_latex block?
>

Yep Nick solution is working fine. I just wonder what is the order of
execution during export. E.g. if I generate the link to a file as
output and place it directly under the lines to add a picture in
org-mode, I thought the code block would be execute first and the
result would replace the function call. The exporter will find a link
to a picture and export it as usual. This was the reason I thought the
following code should work.

#+CAPTION:    my great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
#+srcname: mypicture
#+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
:border 1em :fit
 \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
     \draw[fill=red!50] (0,0) rectangle  ++(5,1);
     \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
     \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
     \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
     \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
 \end{scope}
 \end{tikzpicture}
#+end_src

or alternatively
#+CAPTION:    my great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
#+call: mypicture()


As for putting all figure environment and tikz into one latex-code block.
First of all I thought that :file fig/mypicture.pdf will generate and
process an individual LaTeX file. Thus, I could not use any commands
for the main manuscript right? Sure I could skip the :file command
however, I would prefer to generate each picture as an individual pdf
file. This gives me much more flexibility. I can easily convert them
into any other format and share them individually with co-workers.
Furthermore, many journals are very strict (and minimal) with there
supported LaTeX environment. The tikz package is often not installed
on there machines and the upload process would fail. In addition some
journals require to upload each figure individually. Thus, I am used
already to generate individual pdf-files for each figure and include
them into the manuscript by a simple \includegraphic line.

Thanks for the help

Torsten

CC. I notice something else regarding to babel. Please see my next post

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-08 14:45     ` Torsten Wagner
@ 2011-10-08 19:49       ` Eric Schulte
  2011-10-09  7:30       ` Christian Moe
  1 sibling, 0 replies; 10+ messages in thread
From: Eric Schulte @ 2011-10-08 19:49 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: nicholas.dokos, Org Mode Mailing List

[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]

Torsten Wagner <torsten.wagner@gmail.com> writes:

> Hi Eric
>
>>>
>>> ``:results output silent'' should suppress that I think.
>>>
>>
>> Nick's solution should work well.  Also, (if you're exporting to LaTeX)
>> couldn't you just combine the tikz picture and the wrapping figure
>> environment into a single begin_latex block?
>>
>
> Yep Nick solution is working fine. I just wonder what is the order of
> execution during export. E.g. if I generate the link to a file as
> output and place it directly under the lines to add a picture in
> org-mode, I thought the code block would be execute first and the
> result would replace the function call. The exporter will find a link
> to a picture and export it as usual. This was the reason I thought the
> following code should work.
>

Your code example can be reworked as follows and it should export as
expected.  With a named code block the result may be positioned anywhere
in an Org-mode file regardless of the position of the code block.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: my-great-picture.org --]
[-- Type: text/x-org, Size: 832 bytes --]



The caption, label and attr_latex lines will be applied to the named result.

#+CAPTION:    my great picture
#+LABEL:      fig:my_picture
#+ATTR_LaTeX:
#+results: mypicture
[[file:fig/mypicture.pdf]]


This code block may be anywhere in the Org-mode file the result will
always be placed at the named results line above.

#+srcname: mypicture
#+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz")) :border 1em :fit :results raw
 \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
     \draw[fill=red!50] (0,0) rectangle  ++(5,1);
     \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
     \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
     \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
     \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
 \end{scope}
 \end{tikzpicture}
#+end_src

[-- Attachment #3: Type: text/plain, Size: 1092 bytes --]


Best -- Eric

>
> As for putting all figure environment and tikz into one latex-code block.
> First of all I thought that :file fig/mypicture.pdf will generate and
> process an individual LaTeX file. Thus, I could not use any commands
> for the main manuscript right? Sure I could skip the :file command
> however, I would prefer to generate each picture as an individual pdf
> file. This gives me much more flexibility. I can easily convert them
> into any other format and share them individually with co-workers.
> Furthermore, many journals are very strict (and minimal) with there
> supported LaTeX environment. The tikz package is often not installed
> on there machines and the upload process would fail. In addition some
> journals require to upload each figure individually. Thus, I am used
> already to generate individual pdf-files for each figure and include
> them into the manuscript by a simple \includegraphic line.
>
> Thanks for the help
>
> Torsten
>
> CC. I notice something else regarding to babel. Please see my next post

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [babel] create tikz pictures in an floating LaTeX environment
  2011-10-08 14:45     ` Torsten Wagner
  2011-10-08 19:49       ` Eric Schulte
@ 2011-10-09  7:30       ` Christian Moe
  1 sibling, 0 replies; 10+ messages in thread
From: Christian Moe @ 2011-10-09  7:30 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: nicholas.dokos, Org Mode Mailing List

Hi, Torsten,

Incidentally, I had to remove \end{scope} (there is no corresponding 
\begin{scope}) to make your code example work. Could that be causing 
some of your trouble?

Yours,
Christian

On 10/8/11 4:45 PM, Torsten Wagner wrote:
> Hi Eric
>
>>>
>>> ``:results output silent'' should suppress that I think.
>>>
>>
>> Nick's solution should work well.  Also, (if you're exporting to LaTeX)
>> couldn't you just combine the tikz picture and the wrapping figure
>> environment into a single begin_latex block?
>>
>
> Yep Nick solution is working fine. I just wonder what is the order of
> execution during export. E.g. if I generate the link to a file as
> output and place it directly under the lines to add a picture in
> org-mode, I thought the code block would be execute first and the
> result would replace the function call. The exporter will find a link
> to a picture and export it as usual. This was the reason I thought the
> following code should work.
>
> #+CAPTION:    my great picture
> #+LABEL:      fig:my_picture
> #+ATTR_LaTeX:
> #+srcname: mypicture
> #+begin_src latex :file fig/mypicture.pdf :packages '(("" "tikz"))
> :border 1em :fit
>   \begin{tikzpicture}[line width=1pt,text centered, inner sep = 2]
>       \draw[fill=red!50] (0,0) rectangle  ++(5,1);
>       \draw[fill=yellow!50] (1,1) rectangle  ++(1,0.25);
>       \draw[fill=yellow!50] (3,1) rectangle  ++(1,0.25);
>       \draw[fill=green!50] (0.75,1) rectangle  ++(1.5,-0.4);
>       \draw[fill=green!50] (2.75,1) rectangle  ++(1.5,-0.4);
>   \end{scope}
>   \end{tikzpicture}
> #+end_src
>
> or alternatively
> #+CAPTION:    my great picture
> #+LABEL:      fig:my_picture
> #+ATTR_LaTeX:
> #+call: mypicture()
>
>
> As for putting all figure environment and tikz into one latex-code block.
> First of all I thought that :file fig/mypicture.pdf will generate and
> process an individual LaTeX file. Thus, I could not use any commands
> for the main manuscript right? Sure I could skip the :file command
> however, I would prefer to generate each picture as an individual pdf
> file. This gives me much more flexibility. I can easily convert them
> into any other format and share them individually with co-workers.
> Furthermore, many journals are very strict (and minimal) with there
> supported LaTeX environment. The tikz package is often not installed
> on there machines and the upload process would fail. In addition some
> journals require to upload each figure individually. Thus, I am used
> already to generate individual pdf-files for each figure and include
> them into the manuscript by a simple \includegraphic line.
>
> Thanks for the help
>
> Torsten
>
> CC. I notice something else regarding to babel. Please see my next post
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-10-09  7:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 14:02 [babel] create tikz pictures in an floating LaTeX environment Torsten Wagner
2011-10-07 14:13 ` Nick Dokos
2011-10-07 15:14   ` Eric Schulte
2011-10-07 21:26     ` Darlan Cavalcante Moreira
2011-10-07 21:44       ` Tom Prince
2011-10-08  6:32       ` Achim Gratz
2011-10-08 14:45     ` Torsten Wagner
2011-10-08 19:49       ` Eric Schulte
2011-10-09  7:30       ` Christian Moe
2011-10-08 14:29   ` Torsten Wagner

Code repositories for project(s) associated with this 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).