# [OS X TeX] [TeXShop] input file and master doc compilation

Thu Feb 4 03:21:48 EST 2010

```Alain Schremmer wrote:
>
> On Feb 3, 2010, at 8:18 PM, Herbert Schulz wrote:
>
[]
>> How does TeXshop ``know'' that \jobname refers to the chapter root
>> file if you simply open the chapter file and try to typeset? Don't you
>> have to open the chapter-control file separately and typeset that?
>
> No.
>
> Because the contents file and the control file both have the same
> number, say 2.
>
> Then, when typesetting Chapters-contents/2, the line
>
> %!TEX root = ../Chapters-controls/\jobname.tex
>
> calls
>
> ../Chapters-controls/2.tex

What Herb thinks (as I did) is that this %!TEX line is executed by
TeXShop, which normally does not interpret TeX macros. Thus TeXShop
should be looking for a file with the literal file name
"Chapters-controls/\jobname.tex", which does not exist.

In reality, by some miracle the \jobname macro *is* interpreted
correctly by TeXShop. This is different from setting the project root
via the "File" menu, which creates a *.texshop file containing the file
name. There you cannot use \jobname.

>  which is the root file which contains
>
> \include{../Chapters-contents/\jobname}
>
> namely Chapters-contents/2

This one is clear, the "\include" line is executed by latex, which knows

> that is the original file.
>
> I do think that it is a bit perverse but it really works beautifully.

--
Martin

```