[texshop] ⌘T to main

Sean Bethard sean at seanbethard.com
Sun Aug 11 22:48:23 CEST 2019


Fantastic! That works great, thank you. Exactly what I was looking for.

Also thanks for the tip about syncing with Cmd-Click. That's an
incredible feature I didn't know about.

Sean Bethard

On 8/11/19 8:14 AM, Bruno Voisin wrote:
>> On 11 Aug 2019, at 03:24, Sean Bethard <sean at seanbethard.com> wrote:
>>
>> I'm working on a document with subfiles and would like to map the typset command ⌘T to the main file that defines the subfiles instead of the current file I'm editing. Is there a way to do that?
> This, I think, is done by adding at the top of your main file something like
>
> % !TEX root = ../Main.tex
>
> I haven't used this feature for a very long time (back then it was achieved by a "Set Project Root" item in the File menu, not the "magic" comment above), but I assume this works out-of-the-box.
>
> There's a TeXShop help page devoted to that, in TeXShop's Help Panel at Advanced Help > Setting a Project Root File. I don't know whether there's an online version of the help that could be referred to. In its absence, here's the content of the help page below.
>
> Hope this helps,
>
> Bruno Voisin
>
>
> Settin a Project Root File
> ==========================
>
> It is common to split large input files into several smaller files controlled by a root file. For instance, the root file of a book project might have the form
>
> 	\documentclass[11pt]{book}
> 	\includeonly{Chapter2/two}
> 	\textwidth = 6.5 in
> 	\textheight = 9 in
> 	\begin{document}
> 	\include{Chapter1/one}
> 	\include{Chapter2/two}
> 	\include{Chapter3/three}
> 	\end{document}
>
> This root file contains formatting commands for the entire project, but the subject matter is contained in files one.tex, two.tex, and three.tex. The second line above tells TeX to typeset chapter two only, speeding up typesetting while chapter two is being written. When the book is complete, this line can be commented out and the entire book can be typeset a final time.
>
> While chapter two is being written, it would be natural to open the file two.tex in TeXShop. But after changes are made to this input file, TeXShop should not typeset two.tex; instead it should typeset the root file. TeXShop can be told to do so as follows. Indicate the root file in one of the first twenty lines of each chapter file by writing
>
> 	% !TEX root = ../Main.tex
>
> Note that only the included chapter files need this command; the Root file itself requires no modification.
>
> If the root file is in the same folder as the input file, it is enough to give its name, including the ".tex" extension. For instance, if the root file is named Main, you can enter Main.tex in the first source line or the dialog window.
>
> If the root file is in a different directory, its name can be given relative to the location of the input file. In the above example, the various chapters are contained in subfolders within the folder containing the root file. In that case, you could enter ../Main.tex in the first source line or dialog window, showing the location of the root file relative to the chapter input file.
>
> Finally, the name of the root can be given with an absolute name, as in /Users/me/Main.tex.
>
> If the entire TeX source is contained in a single file, it is not necessary to set the root project name.
>
> TeXShop has a Macro in the Macros menu which makes setting this "root line" almost automatic.
>
> Setting a project root is also important for synchronization. If input lines have a "% !TEX root = ..." line, then synchronizing from the Preview window to the Source window will open the appropriate source chapter file and bring make that source window active. 
>
> If a root file is active, typing command-1 when a given source window is at the front will activate the corresponding preview window. Typing command-1 again will activate the source window. Since a preview window may correspond to several source windows, command-1 will activate the source window which previously activated the preview window, or the root source if no previous command-1 was entered. 
>
> TeXShop had an alternate method of setting the root file, activated by the menu command "Set Project Root..." This method will continue to be supported in the future, but should not be used because the "% !TEX root = ..." method is more robust. Consequently, the "Set Project Root..." command has been removed from TeXShop menus. When the "Set Project Root.." command was used to indicate a root file, TeXShop remembered the name of the root file by writing the information to a file with the same name as the input file and the extension ".texshop". For instance, if the input for chapter two was in two.tex, TeXShop wrote the name of the root in two.texshop in the same directory as two.tex. If the file two.texshop was later thrown away, TeXShop would revert to typesetting two.tex rather than Main.tex.
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://tug.org/pipermail/texshop/attachments/20190811/e166053c/attachment-0001.sig>


More information about the texshop mailing list