[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [babel] Literate Programming for publication
From: |
Torsten Wagner |
Subject: |
[O] [babel] Literate Programming for publication |
Date: |
Wed, 11 Apr 2012 23:35:16 +0900 |
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>}
- [O] [babel] Literate Programming for publication,
Torsten Wagner <=