[NTG-pdftex] About SyncTeX and output-directory option

Jérome Laurens jerome.laurens at u-bourgogne.fr
Fri Jan 22 13:31:12 CET 2010


Hi fellows,

I have just subscribed to the list in order to give, as the SyncTeX developer,  more informations about
the question raised earlier by Martin Reinders titled "...SyncTeX and output-directory option"
and brought to my attention by Karl Berry.

(BTW, sorry for breaking the message thread)

As noticed by Martin, since TeXLive 09 the .synctex file is always created in the same directory as the pdf output.
This is the only way to tell a pdf viewer that there exists some synctex information around.

But, as pointed out in Martin's mail, the problem is that all the input file names are recorded relative to the current directory according to pdftex,
which is not the current directory according to the pdf viewer.
The consequence is that the relative file names recorded in the .synctex file are broken and useless if we do not know the original input directory.

We can consider that this is a limitation in synctex code.
However, this is (partly) intentional due to the following reasons
1) I don't know for sure how to deal with paths in a OS independent way (actually synctex code already contain parts dedicated to windows OS)
2) I have not made my mind on how to manage this problem properly
3) There is a poor man's workaround implemented in frontends like iTeXMac2 AFAIR

Martin proposed to apply a post processing perl script to change in the .synctex.gz file the relative paths to the "appropriate" values.
Unfortunately, this breaks forwards synchronization and will certainly break backwards synchronization too
if we further move the pdf output file and its synctex.gz companion to another directory.
So this solution is not satisfying.

Let me explain what is point 3) above when the main input file is main.tex
First we can assume that output-directory is - by pdftex design - a subdirectory of the folder containing main.tex
If the full path of the output file is /foo/bar/main.pdf,
then synchronization from view to source may work as follow

if /foo/bar/main.tex exists then
	assume that all relative input file names in the .synctex file are relative to /foo/bar
else if /foo/main.tex exists then
	assume that all relative input file names in the .synctex file are relative to /foo
else if /main.tex exists then
	assume that all relative input file names in the .synctex file are relative to /
else
	no synchronization info is available

No need to modify the .synctex file, this will solve -in general- the problem when implemented in the synctex aware pdf/dvi viewer.


BTW, I tend to use "Factory" as output directory name:

pdflatex --output-directory "Factory" main.tex

Adopting such a rule would render document sharing more friendly:
frontends could use something like

if there exists a "Factory" folder then
	pdflatex --output-directory "Factory" main.tex
else
	pdflatex --whatsover main.tex

Also, when trying to synchronize forward from ./main.tex, a front could do something like

if ./main.pdf exists
	use if
else if ./Factory/main.pdf exists
	use it
else
	no forward synchronization is available

Moreover, when intermediate tools are used to create input material,
like for example graphic charts form statistical data,
the graphic file can go to this Factory folder such that
the front end just has to launch

pdflatex --output-directory "Factory" --input-directory "Factory" main.tex

In short, my suggestion would be to somehow hard code "Factory" (or any appropriate name) as output directory name.


regards

Jerome Laurens, temporarily listening to pdftex



More information about the ntg-pdftex mailing list