[texworks] %!TEX root =

Stefan Löffler st.loeffler at gmail.com
Mon Jan 5 17:21:50 CET 2009


On 2009-01-01 20:40, Jonathan Kew wrote:
> On 1 Jan 2009, at 19:10, Joseph Wright wrote:
>
>> Ah, I see the issue. I have a sub-doc with !TEX root = <whatever>, and
>> in the main file !TEX program = pdflatex. However, the default engine
>> is pdfTeX. So when I Ctrl+T in the sub-doc, TeXworks ignores the engine
>> spec. in the main file and tries to pdfTeX it. Result: compilation
>> fails.
>>
>> I'd expect the engine spec in the main file to be respected here, I
>> think.
>
> [...] What if you have conflicting "program = ..." specifications in
> the current file (sub-document) and the root document; which should be
> used then?
>
> The way "program = ..." is handled in TeXworks is slightly different
> from TeXShop, if you're familiar with its behavior. In TS, any
> "program = ..." specification *overrides* the engine that's selected
> in the toolbar popup, so Cmd-T always uses what the file specifies. In
> TW, on the other hand, the "program = ..." specification initializes
> the popup to the chosen setting when the file is opened (or when the
> specification is edited), but if the user then changes it manually,
> the new choice will be respected.
>
> This means that when you press Cmd-T (Ctrl-T), TeXworks relies on the
> toolbar popup to tell it what to do; it doesn't inspect the "program =
> ..." line at this time. And so the engine you get is the one that's
> selected in the window where you press Cmd-T.

I'd propose the following modification to deal with the problems mentioned:
Add an item titled "Auto" to the engine selection drop down menu. The
typeset process would then be the following:
Is "Auto" chosen as the engine?
If no: use the selected engine
If yes: does the current document have a "program=..." spec?
If yes: use the specified program
If no: is there a "root=" spec and does the root document have a
"program=..." spec?
If yes: use it
If no: use the default engine

The default engine could simply be set (this is the behavior right now)
or could be derived from the extension, certain content elements, etc.

This way, the user can always override the automatic behavior (useful
i.e. to run BibTeX on a document which is normally typeset with LaTeX).
In addition, a "project"-wide behavior can be specified by including a
"program=..." spec in the root document which can be overridden in any
sub-document.

-Stefan


More information about the texworks mailing list