[texworks] Programmatic access to subsidiary file name

Joel C. Salomon joelcsalomon at gmail.com
Thu Aug 23 13:46:22 CEST 2012


On Wed, Aug 22, 2012 at 6:32 AM, Philip TAYLOR <P.Taylor at rhul.ac.uk> wrote:
> Calibri.tex, Garamond.tex, etc., all start with two pragmats :
>
>         % !TeX Program = XeTeX,
>         % !TeX root = Genealogy.tex
>
> but my main file (Genealogy.tex) contains an explicit \input statement :
>
>         \input  Calibri % Garamond % CMR % etc.
>
> Is there any mechanism within TeXworks for interpolating the name of
> the dependent file into the main file[?]
<snip>
> Obviously this would require that the primary file be fed not directly
> into the compiler but rather via a pre-processor, but that does not
> seem excessively onerous in terms of the benefits thereby gained.

There's no feature currently in TeXworks that can directly do what you
want.  I would also strongly NOT support adding this feature as you
describe it: writing to another source file is just asking for
trouble.

That said, there's a kluge you can use, and a feature that might be
suitable to add to TeXworks.  First the kluge:

Define a few new typesetting commands: XeTeX-Calibri, XeTeX-Garamond,
&c.  These are copies of the XeTeX, but with one new argument added at
the end of the list: the string "\def\FontFile{Calibri}" (possibly
with the quote marks).  Calibri.tex will now start with these lines
instead:

  % !TeX program = XeTeX-Calibri
  % !TeX root = Genealogy.tex

Garamond.tex will refer to XeTeX-Garamond, &c., &c.  Genealogy.tex
will "\input\FontFile", demanding that this be defined on the
command-line.  Yeah, this is a kluge.

The feature that might be appropriate for TeXworks would eliminate the
kluge, instead adding a new pragma to TeXworks.  Calibri.tex would
then start with these lines:

  % !TeX program = XeTeX
  % !TeX root = Genealogy.tex
  % !TeX arguments = "\def\FontFile{Calibri}"

When TeXworks is told to typeset from within Calibri.tex, it will then
run XeTeX on Genealogy.tex, appending to the command-line the argument
"\def\FontFile{Calibri}".

This feature does not exist yet, though; but the kluge above will
(sort of) work.

--Joel


More information about the texworks mailing list