> On Mon, Jun 18, 2012 at 6:50 PM, John Hendy <jw.he...@gmail.com> wrote: > > #+name: preamble > > #+begin_src R :exports none > > tikzDevice("file-name") > > #+end_src > > Are you trying to use "file-name" as a variable? if so I think the > source block header should include this: ":var file-name" and the source > block can refer to the variable as $file-name.
It seems to me one of both ,----[ insert preamble ] | <<preamble>> | with the preamble having the header | :var file-name="file_1.tex" `---- or ,----[ eval preamble ] | <<preamble(file-name="file_1.tex")>> | without any :var header `---- would be correct syntax, but using :var <variable> without assigning it should fail (though I didn't test it). Both wouldn't give the same result… > > And by the org-mode Babel documentation it looks like I can do > > something like: > > > > <<preamble(file-name=file_1.tex)>> > > I'm not sure about this. The syntax seems correct but I don't quite > understand the following statement from the manual: > > It is possible to include the _results_ of a code block rather than > the body. This is done by appending parenthesis to the code block name > which may optionally contain arguments to the code block as shown > below. > > <<code-block-name(optional arguments)>> … as I read this as "the noweb reference will expand in either 1. The litteral of the code-block if there are no parenthesis 2. The results of the block (as obtained with C-c C-c or org-babel-execute-src-block) (which may depend of a :results header, maybe), if parenthesis are present. " So if the OP wants to call the preamble block with an argument in the noweb reference, then the preamble block might have to be more like #+name: preamble #+begin_src R :results output print(tikzDevice(file-name)) #+end_src called with <<preamble(file-name="file_1.tex")>> (but I don't know any R either, I just went myself through variable substitution over the weekend) Last alternative, which I use, is putting the file name in some named table, and then passing it as an argument to ,----[ insert preamble ] | <<preamble>> | with the preamble having the header | :var file-name=some-table[0,1] `---- (Like #+tblname: some-table | file | "file_1.tex" | ) HTH, William