[texworks] %!TEX tags

Stefan Löffler st.loeffler at gmail.com
Sat Jun 26 18:03:21 CEST 2010


Hi,

Am 2010-06-26 16:59, schrieb Alain Schremmer:
>
> On Jun 26, 2010, at 3:36 AM, Stefan Löffler wrote:
>
>> Am 2010-06-24 18:07, schrieb Alain Schremmer:
>>
>>> I am a completely satisfied user of TeXShop and am inquiring in
>>> consideration of the windows users of my stuff which uses this line
>>> systematically.
>>
>> I think this is an intriguing feature, though I'm not sure if most
>> "standard" users will know about the meaning of \jobname.
>
> You are right, \jobname is not well known: it appears in passing on
> page 754 of Companion 2ed. But it is a most useful command when you
> have many similar files made from a template.

[skipped example code]

> Thus, I can compile a chapter either from the Content file or from the
> Control file will typeset just the chapter.

Yeah, I was thinking about something along this line as well.

>> Is this astandard TeXShop feature (in which case I think we should
>> keep it, for
>> the sake of cooperation)?
>
> What is a feature of TeXShop is that, much to the disbelief of many,
> it understands \jobname in that first line. Through sheer idiot's
> luck, I knew and used that but it took Koch to explain why. I am quoting:
>
> So I looked at the routine "decodeFile" and discovered this comment:
>
>      // added by John A. Nairn
>   // get full path name for possible relative file name in relFile
>   // relative is from home
>
> and the last lines of the routine read
>
>     // see if \jobname is there
>     searchString = [self filterBackslashes:@"\\jobname"];
>     aRange = [saveName rangeOfString:searchString
> options:NSLiteralSearch];
>     if(aRange.location == NSNotFound)
>         return saveName;
>
>     // replace \jobname(s)
>     saveTemp = [NSMutableString stringWithString:saveName];
>     [saveTemp replaceOccurrencesOfString:searchString
> withString:jobname options:NSLiteralSearch
>                                    range:NSMakeRange(0,[saveName
> length])];
>     return [NSString stringWithString:saveTemp];

Without knowing too much about TeXShop's code, I'd say that's pretty
much exactly what I posted as a patch on Google Code.

>> If not, maybe it would be better to change
>> this to something a little more intuitive, like "$basename" (keeping
>> with the notation for typesetting tools).
>
> Here I am not following you. What is "$basename"? It does not seem to
> appear in Companion 2ed.

No, it's no standard. But the tool definitions in Tw (e.g., the command
line to run pdflatex) include some options, must notably "$fullname"
which expands to the full path + filename of the file that is to be
typeset. In analogy, I was proposing to recognize something like
"$basename", which is the common term (at least for programmers) to
refer to the filename without the extension.

> But it makes me think of  an extremely useful command in Didier
> Verna's FINK. Here is how I am using it:
>
> \xdef\CheckableItem{\finkdir-\finkbase}
> \ifthenelse{\boolean{Quiz?}}%
> {%begin Quiz? true
> \UseProblem{\CheckableItem-q}%
>         {%
> QUIZtext%
> [...]
>
> Doesn't look like much but given that I have 900 such pages ...
>
> I have forgotten now but, at one point, it would have made my life a
> lot easier had I been able to use FINK's tools in that first line tag.
> Unfortunately, John A. Nairn does not seem to have known about it.

Well, using FiNK's tools is simply impossible, because I guess they rely
on the actual LaTeX run up to that point. In fact, also the use of
\jobname doesn't really use the LaTeX symbol, but rather emulates its
behavior as Tw simply replaces it by the actual file name. But providing
the different parts of the current file's path (e.g., $fullname,
$basename, $fileext, $filedir) should be possible easily. Support for
something like \maindir on the other hand won't be easy to accomplish
right now, though. Maybe if we start working on project support some day...

HTH
Stefan


More information about the texworks mailing list