[OS X TeX] SyncTeX (or TeXShop/TeXworks) suggestion (if the feature is not already there…)

roberto avanzi roberto.avanzi at online.de
Mon Jun 24 21:41:29 CEST 2013


Suppose that we have a master file that can include several files that can also be compiled individually.
This can happen, for instance, with any of the solutions mentioned here

http://tex.stackexchange.com/questions/45558/merging-many-tex-documents-together

or for instance with the method explained here

http://tex.stackexchange.com/questions/9931/headings-and-advice-to-write-a-phd-in-physics-using-latex/9949#9949

the important use case is the following: several authors write independently "Sections" of a report, and an editor just has to \input the files without any changes to create the report.  This is a concrete situation and in fact one that I am exploring for my own work.  Also, at the beginning of the files of the individual sections there is no "% !TEX root = masterfile.tex" command. This is important since there can be several rounds of interactions between main editor and section authors.

Now comes synctex. If I cmd-click in the preview, I am always redirected to the correct place in the source files.
However, if I am cmd-clicking in the source file of an individual section, synctex (texshop/texworks) will try to find the associated pdf file - which is fine for the editor of an individual section but NOT for the main editor.  Of course if a !TEX root command is set at the beginning of the section file synctex will sync with the master file, but adding and removing this line is against the spirit of the concept I am exploring.

There are possibly solutions. synctex defined already a \synctex value that can be programmatically set. If the master file had a \overridesynctexfile variable that can be programmatically set, this could override the current settings.  So, for instance, if in the  master file we define \overridesynctexfile=1 this would mean: for each file included with \input or \include in a directory that is "lower or equal" than the current create a dummy .synctex file that just redirects to the main one for this doc (or make it into a soft link to it). Otherwise  the default value \overridesynctexfile=1 means: old behaviour.

Of course I can add a single line with a !TEX root command at the beginning of the line and the authors of individual sections just have to add/remove, say, a "x" after the first % sign to invalidate/validate it.  But it is a bit inconvenient.

Another option, that it perhaps easier, since it involves only minimal intervention from the authors of TeX editing environments, is to add a checkbox on the title bar of each editor window, that means "Ignore Tex root command".  Then the "% !TEX root = masterfile.tex" line can be left there and the section editors just have to click on that.  Ideally, this feature should spread to the main TeX editing environments, since I am going to use TeXShop under OS X and TeXworks everywhere else, "main" here means jut these two.

 Roberto


More information about the macostex-archives mailing list