emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] Literate Programming for publication
@ 2012-04-11 14:35 Torsten Wagner
  2012-04-11 15:29 ` Thomas S. Dye
  0 siblings, 1 reply; 3+ messages in thread
From: Torsten Wagner @ 2012-04-11 14:35 UTC (permalink / raw)
  To: Org Mode Mailing List

Hi,

I just try (again) to use org-mode and babel for literate programming
finally resulting in a camera ready manuscript for publication.

I noticed that there are different ways of achieving this and wonder
what others use or what others think might be the best.

What I want do
Ideally, I would like to separate the org-file into three parts
1. org-mode itself containing all kind of infos, notes, dates,
links,etc -> for me and possibly co-authors
2. latex stuff, the parts which should present the final manuscript ->
to the publisher, colleagues, etc
3. code, all the code to munch all input data into some graphs and to
distill the final results -> for me, coauthors and people who request
it.

What I managed to do
Today I started again combining python resp. pylab and matplotlib
together with org-mode
I managed to use
* python source code blocks in session mode -> generation of graphs in
png format
* org-mode native text -> all text of the manuscript including the
generated figures

At this point I noticed I could use latex source code blocks or latex
code blocks but I had the following problem with both of them.

In python I define certain variables
e.g.

#+begin_src python
U = 3 # applied voltage
t  = pl.arange(0,3.1,0.1) # time
#many more...
#+end_src

later in the text I have to write this parameters as well.
e.g.

.... as shown in figure 3 the current increase after applying a
voltage pulse with an amplitude of 3 V for 3 seconds....

Now here comes the problem. If I start playing around with my python
code I might end up with different values in the calculation and in
the text. This is very hard to spot and hence very dangerous to
overlook.

Thus, I used something like
 .... as shown in figure 3 the current increase after applying a
voltage pulse with an amplitude of src_python[:session name]{print(U)}
V for  src_python[:session]{print(t[-1]} seconds....

The code blocks will be replaced on export and the original text will
be the exported.

Now, I have only one place to change parameters all numbers would be
valid for both code and text.
However, this did not work within latex code blocks or latex blocks.
Having all text in org mode outline, however does not allow me to
separate easily publishable text and notes.
Maybe I could use drawers and property nodes etc. but I think this
looks to make thinks even more complex.
Finally, the biggest problem is the fact that I can't tangle the
entire org-file into different files. I really would like to get
* a tex/pdf/odt manuscript file for the publishers
* a pdf/org/html/odt file including all and everything
* a python source file.

How can I manage to use different code blocks (latex and python) but
still be able to inject results from python into the latex code
blocks? noweb and vars looked good but it did not work for me.

Thanks for all input

Torsten
src_<language>{<body>}

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

* Re: [babel] Literate Programming for publication
  2012-04-11 14:35 [babel] Literate Programming for publication Torsten Wagner
@ 2012-04-11 15:29 ` Thomas S. Dye
  2012-04-12 10:55   ` Olaf.Hamann
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas S. Dye @ 2012-04-11 15:29 UTC (permalink / raw)
  To: Torsten Wagner; +Cc: Org Mode Mailing List

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

> Hi,
>
> I just try (again) to use org-mode and babel for literate programming
> finally resulting in a camera ready manuscript for publication.
>
> I noticed that there are different ways of achieving this and wonder
> what others use or what others think might be the best.
>
> What I want do
> Ideally, I would like to separate the org-file into three parts
> 1. org-mode itself containing all kind of infos, notes, dates,
> links,etc -> for me and possibly co-authors
> 2. latex stuff, the parts which should present the final manuscript ->
> to the publisher, colleagues, etc
> 3. code, all the code to munch all input data into some graphs and to
> distill the final results -> for me, coauthors and people who request
> it.
>
> What I managed to do
> Today I started again combining python resp. pylab and matplotlib
> together with org-mode
> I managed to use
> * python source code blocks in session mode -> generation of graphs in
> png format
> * org-mode native text -> all text of the manuscript including the
> generated figures
>
> At this point I noticed I could use latex source code blocks or latex
> code blocks but I had the following problem with both of them.
>
> In python I define certain variables
> e.g.
>
> #+begin_src python
> U = 3 # applied voltage
> t  = pl.arange(0,3.1,0.1) # time
> #many more...
> #+end_src
>
> later in the text I have to write this parameters as well.
> e.g.
>
> .... as shown in figure 3 the current increase after applying a
> voltage pulse with an amplitude of 3 V for 3 seconds....
>
> Now here comes the problem. If I start playing around with my python
> code I might end up with different values in the calculation and in
> the text. This is very hard to spot and hence very dangerous to
> overlook.
>
> Thus, I used something like
>  .... as shown in figure 3 the current increase after applying a
> voltage pulse with an amplitude of src_python[:session name]{print(U)}
> V for  src_python[:session]{print(t[-1]} seconds....
>
> The code blocks will be replaced on export and the original text will
> be the exported.
>
> Now, I have only one place to change parameters all numbers would be
> valid for both code and text.
> However, this did not work within latex code blocks or latex blocks.
> Having all text in org mode outline, however does not allow me to
> separate easily publishable text and notes.
Aloha Torsten,

I tried using latex code blocks and found that they were more trouble
than they were worth.  The LaTeX exporter works well for preparing
drafts to submit to journals.  Nicolas Goaziou's exporter project seems
to be very nice and an improvement, so I would recommend keeping all
text in the Org mode outline, rather than using latex code blocks.

I separate the publishable text from the notes and code blocks with tags
for the headlines in my Org mode files.  I have this at the top
of the file:

#+EXPORT_EXCLUDE_TAGS: noexport

Then:

* Some publishable text

* Some notes :noexport:
* Some code :noexport:


> Maybe I could use drawers and property nodes etc. but I think this
> looks to make thinks even more complex.
> Finally, the biggest problem is the fact that I can't tangle the
> entire org-file into different files. I really would like to get
> * a tex/pdf/odt manuscript file for the publishers
Export to latex or odt, possibly with the new exporter

> * a pdf/org/html/odt file including all and everything
Adjust the tags accordingly, or #+EXPORT_EXCLUDE_TAGS:, and re-export

> * a python source file.
It should be possible to tangle this in the usual way.  Depending on
what you want, perhaps a master code block would work:

#+begin_src python :noweb yes :tangle master.py
<<code-block-1>>
<<code-block-2>>
#+end_src 

This involves keeping track of the different code blocks, and there is
likely a better way to do this, but the approach should work.

hth,
Tom

>
> How can I manage to use different code blocks (latex and python) but
> still be able to inject results from python into the latex code
> blocks? noweb and vars looked good but it did not work for me.
>
> Thanks for all input
>
> Torsten
> src_<language>{<body>}
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: [babel] Literate Programming for publication
  2012-04-11 15:29 ` Thomas S. Dye
@ 2012-04-12 10:55   ` Olaf.Hamann
  0 siblings, 0 replies; 3+ messages in thread
From: Olaf.Hamann @ 2012-04-12 10:55 UTC (permalink / raw)
  To: emacs-orgmode

> Torsten Wagner<torsten.wagner@gmail.com>  writes:
>>
>> How can I manage to use different code blocks (latex and python) but
>> still be able to inject results from python into the latex code
>> blocks? noweb and vars looked good but it did not work for me.

Hi Torsten,
chapter 14.8.2.1 of the Org Mode Manual shows in detail how one can use 
result output from one src block as header argument :var  input (input 
may be a org table, list, codeblock with arguments (!) , literal or even 
emacs lisp).
Does that fit your needs?
Could you give a concrete example with your requirements, that I could 
play with, say over weekend?
I'm just a beginner with org-babel, but very interested in using LP in 
real project stuff.

Greetings, Olaf

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

end of thread, other threads:[~2012-04-12 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-11 14:35 [babel] Literate Programming for publication Torsten Wagner
2012-04-11 15:29 ` Thomas S. Dye
2012-04-12 10:55   ` Olaf.Hamann

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).