Jos'h Fuller <Jos'h.ful...@arcproductions.com> writes: > Hi! > > I was writing some documentation about how to use a Python function, so I > decided to try the tangling feature. However, the result, when exported to > PDF, is unsatisfactory because the referenced code block is included twice -- > first in the original location, then again where I referenced it with > <<function-definition>>. > > This is, of course, exactly what it needs to do to be able to execute the > code properly and show the result. But it doesn't look nice. Is there any way > to suppress the second printing inside the function-demo block? > > If this isn't clear from the example below, I can provide examples of the > duplication in action as well as what I'd like the output to look like. > > Thanks very much! > > Example file: > #+TITLE: Tangle Test > #+LANGUAGE: en > #+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:nil -:t f:t *:t <:t > #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc > > * Tangled Code > I want to show the definition of a function first: > #+name: function-definition > #+begin_src python :tangle yes :exports code > def entable(data): > if not data: return "/No data./" > > columns = len(data[0]) > sizes = [0,]*columns > for row in data: > sizes = [max(x) for x in zip(sizes, [len(str(t)) for t in row])] > > format = "| " + " | ".join(["%%%ds" % x for x in sizes])+" |" > return "\n".join([format % tuple(row) for row in data]) > #+end_src > > Now I want to show a demonstration of how the function might be > called. I need the function to be included so that demonstration > code can be executed, but I don't want to include the function > definition twice: > > #+name: function-demo > #+begin_src python :tangle yes :exports both :noweb yes :results output > <<function-definition>> > > print entable([["One", 2, 3],["Four", 5, 6], ["Seven", 8, 9]]) > #+end_src > > Which gives us this result: > > #+results: function-demo > : | One | 2 | 3 | > : | Four | 5 | 6 | > : | Seven | 8 | 9 | > > Aloha!
Does the :no-expand header argument do what you want? See http://orgmode.org/manual/no_002dexpand.html#no_002dexpand. hth, Tom -- Thomas S. Dye http://www.tsdye.com