From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: org-babel: Meta-LaTeX-Python-Environment Date: Wed, 28 Oct 2009 12:57:28 -0400 Message-ID: <871vknlamf.fsf@stats.ox.ac.uk> References: <200910261327.09576.torsten.wagner@googlemail.com> <878wexheeq.fsf@stats.ox.ac.uk> <4edb2bbc0910270625ybce9255nf569b5e250d061e1@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N3Bq7-0002XS-RV for emacs-orgmode@gnu.org; Wed, 28 Oct 2009 12:57:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N3Bq3-0002TI-3F for emacs-orgmode@gnu.org; Wed, 28 Oct 2009 12:57:39 -0400 Received: from [199.232.76.173] (port=46091 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N3Bq2-0002TD-VK for emacs-orgmode@gnu.org; Wed, 28 Oct 2009 12:57:34 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:45211) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N3Bq2-0003SH-Bt for emacs-orgmode@gnu.org; Wed, 28 Oct 2009 12:57:34 -0400 In-Reply-To: <4edb2bbc0910270625ybce9255nf569b5e250d061e1@mail.gmail.com> (Torsten Wagner's message of "Tue, 27 Oct 2009 22:25:15 +0900") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Torsten Wagner Cc: emacs org-mode mailing list [cc'ing list who were accidentally omitted] Torsten Wagner writes: > Hi Dan, > =C2=A0 > > > > 1. Hiding of the source code blocks for export > > I like to export the results of the source code block to LaTeX only. > However, > > Using ':exports results' specifies that only the results should appear > in the exported document. This > > #+begin_src python :exports results > =C2=A06 + 6 > #+end_src > > Hi Torsten > I tried this but the result is first the source code block followed by the > result: If it's not working, could you provide the exact example and tell us your operating system, git version etc? > Furthermore, I tried to create some LaTeX code as result of the code block You need to use the ':results latex' header if you want the result to be output as latex. <...> > In general I could try to use org-mode as much as possible. However, in t= hat > special case I like to merge three (or more) documents together. > 1. The source code (e.g. python) > 2. A laboratory journal (this would use org-mode magic) > 3. An official report e.g. a manuscript to be submitted to a journal (this > would be a LaTeX file) > > The idea is to be able to merge all this together to make sure data > manipulation and calculus (source code) are as close as possible to the > specific journal entry, which may supply additional important information= and > the final manuscript snippets which presents officially the particular re= sult. > A short example would be (without real headers) > > --8<-------------------------------------------------------------->8--- > * 23.10.09 > Measurement this morning was performed as usual but this time without war= m up > of device foo. > Measurement file is saved under _link_. > TODO: Don't forget to prepare for meeting tomorrow > > <> > for foo import * > a =3D load("data.csv") > b =3D apply_filter(a,lp) > plot(b) > saveplot(bar.pdf) > <> OK, currently, the way to do that is something like #+srcname: pyplot(file=3D"bar.pdf") #+begin_src python :results file plot(outfile=3Dfile) file #+end_src =20 #+resname: pyplot [[file:bar.pdf]] Note that for a generalist language like python (which does not always create output to file) you currently need to 1. specify that it outputs a file with ':results file' 2. explicitly send output to the file in your python code 3. explicitly return the filepath as a string at the end of the block. it will get inserted as a link. You have the option of not hard-wiring the filepath in the python code by using a variable as I did there. [We may want to change this so that (3) happens automatically when ':file filepath' or ':results file' is provided] > > First low pass filter was applied then a plot is generated > This plot will be used in publication for journal foo > DEADLINE: <2009-12-14 Mo> > <> > \begin{figure} > =C2=A0 \includegraphics{bar.pdf} > \end{figure} > <> To avoid hard-wiring the filename into the latex block you could use the org-babel-latex.el that Eric has posted. > =C2=A0--8<-------------------------------------------------------------->= 8--- > > Text outside should be org-mode text. > Now I like to export with three scenarios > 1. Only the LaTeX part (e.g. by using tangle) resulting in a pure native > LaTeX-file ready for submission See emails in the concurrent main thread on this topic. > Above example will result in > > \begin{figure} > =C2=A0 \includegraphics{bar.pdf} > \end{figure} > > 2. The LaTeX part and the org-mode parts whereas the LaTeX blocks should = be > somehow verbatim > or in a some way marked inline. Above example should result in a LaTeX ex= port > like=C2=A0 'begin_src latex' blocks are exported as code blocks with appropriate fontification under org-mode. I hope this is getting clearer now :) Dan > > \section{23.10.09} > Measurement this morning was performed as usual but this time without war= m up > time. > Measurement file is saved under \footnote[/home/foo/data.csv]{link}. > First low pass filter was applied then a plot is generated > This plot will be used in publication for journal foo > \begin{minipage} > \begin{figure} > =C2=A0 \includegraphics{bar.pdf} > \end{figure} > \end{minipage} > > 3. Export of all which will include the python blocks in a inline form as= well. > > First of all I would be happy if I could avoid to have the source code bl= ocks > in the export file. > I simply like to generate LaTeX-snipplets in python and export a LaTeX fi= le > finally. > > Thus, > > #+srcname: LaTeX > #+begin_src python :session :exports results > =C2=A0 plot([1,2,3,4,5],[2,4,6,8,10]) > =C2=A0savefig(file,f-acecolor=3D'w', edgecolor=3D'w',format=3DNone) > =C2=A0param1 =3D 19.7 > =C2=A0perf =3D 77 > #+end_src