emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [babel] Literate Programming for publication


From: Thomas S. Dye
Subject: Re: [O] [babel] Literate Programming for publication
Date: Wed, 11 Apr 2012 05:29:33 -1000

Torsten Wagner <address@hidden> 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



reply via email to

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