emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: emacs-orgmode Mode <emacs-orgmode@gnu.org>
Subject: export: inserting text between source and its results
Date: Fri, 8 Jun 2012 09:48:34 +0200	[thread overview]
Message-ID: <9F1FC8FF-6FCF-40F1-8881-E62D386160AF@polytechnique.org> (raw)

Hello,

I'm writing a presentation with some source code blocks. At the moment I can easily evaluate them and have them display in a pretty way (using the :results code flag). For instance, the following

> Evaluating
> 
> #+name: with_example
> #+begin_src js :results code output :exports both
> var x = 1
> var f = function(o){ with(o){ return x } }
> var o2 = { x : 2 }
> var o3 = { x : 3 }
> console.log(f({}))
> console.log(f(o2))
> console.log(f(o3))
> #+end_src

gives me something very nice in LaTeX

> Evaluating
> 
> \begin{minted}[frame=lines,fontsize=\scriptsize]{js}
> var x = 1
> var f = function(o){ with(o){ return x } }
> var o2 = { x : 2 }
> var o3 = { x : 3 }
> console.log(f({}))
> console.log(f(o2))
> console.log(f(o3))
> \end{minted}
> 
> \begin{minted}[frame=lines,fontsize=\scriptsize]{js}
> 1
> 2
> 3
> \end{minted}
> \end{frame}

Now I would like to insert some text between the source part and the result part. For this it seems that I need to use a "call", but then I can't see how to get it to display nicely in a minted environment. Here is what I tried:

> Evaluating
> 
> #+name: with_example
> #+begin_src js :results output :exports source
> var x = 1
> var f = function(o){ with(o){ return x } }
> var o2 = { x : 2 }
> var o3 = { x : 3 }
> console.log(f({}))
> console.log(f(o2))
> console.log(f(o3))
> #+end_src
> 
> Results
> 
> #+call: with_example() :results code

yields

> Evaluating
> 
> \begin{minted}[frame=lines,fontsize=\scriptsize]{js}
> var x = 1
> var f = function(o){ with(o){ return x } }
> var o2 = { x : 2 }
> var o3 = { x : 3 }
> console.log(f({}))
> console.log(f(o2))
> console.log(f(o3))
> \end{minted}
> 
> Results
> 
> \begin{minted}[frame=lines,fontsize=\scriptsize]{common-lisp}
> "1\n2\n3\n"
> \end{minted}
> \end{frame}

(It seems the ":results code" evaluates again the output of the call.)

Any suggestion?

Thanks a lot,

Alan

             reply	other threads:[~2012-06-08  7:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-08  7:48 Alan Schmitt [this message]
2012-06-08  8:57 ` export: inserting text between source and its results Sebastien Vauban
2012-06-08 14:06   ` Alan Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9F1FC8FF-6FCF-40F1-8881-E62D386160AF@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).