[texworks] Access to filename of edited file in external command

Duncan Murdoch murdoch.duncan at gmail.com
Tue Aug 3 16:01:47 CEST 2010


I am trying to set up TeXworks (in MikTeX on Win7, but that probably 
doesn't matter) to run Sweave as a typesetting tool.  Sweave is a 
literate programming tool in R modelled after noweb.  Input is a source 
file mixing R code with LaTeX code, output is pure LaTeX for typesetting.

In a large project one would typically break up the text into chapter 
files, and have a main wrapper to input them all. TeXworks handles this 
with a line like

% !TeX root = wrapper.tex

near the top of the chapter file, so TeXworks runs LaTeX on the wrapper 
file, not the individual chapter file.  The problem is that Sweave needs 
to know
which chapter you were working on so it can preprocess it into LaTeX 
code.  It appears that there is no substitution string in TeXworks that 
contains the name
of the original chapter file.  Once you include the line above, the only 
substitutions available are based on wrapper.tex.

Is that correct?  (I can do various workarounds within Sweave if 
necessary, but it would be nice not to have to invent yet another way to 
specify the wrapper.)

Duncan Murdoch


More information about the texworks mailing list