About SyncTeX and output-directory option
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
Hi, On Fri, 22 Jan 2010, Jérome Laurens wrote:
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 it must be a special viewer knowing about synctex. Couldn't one then put the required path info into the PDF file, e. g., as some special comment, or even as /PTEX_SYNCTEX_PATH key into the info dir or catalog?
In short, my suggestion would be to somehow hard code "Factory" (or any appropriate name) as output directory name.
i guess this would make the overall system rather inflexible. Regards, Hartmut
Hartmut Henkel
Hi,
On Fri, 22 Jan 2010, Jérome Laurens wrote:
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 it must be a special viewer knowing about synctex. Couldn't one then put the required path info into the PDF file, e. g., as some special comment, or even as /PTEX_SYNCTEX_PATH key into the info dir or catalog?
Yes, my comment was a bit short. In fact, SyncTeX also works with dvi such that some equivalent to /PTEX_SYNCTEX_PATH should be defined for dvi and xdv files. Moreover, all the dvi2pdf and xdv2pdf tools should also support this kind of enhancement. It would be perfectly possible but this is not really something I'd like to do myself.
In short, my suggestion would be to somehow hard code "Factory" (or any appropriate name) as output directory name.
i guess this would make the overall system rather inflexible.
Not really. This is just a matter of convention: if someone wants to use the pdftex output directory option and does not really know what name to choose, he can simply use "Factory". That would make life easier when sharing documents as folders. And that would give a better UI experience for newcomers or beginners. Anyway, that is out of topic on this list. Cordialement, Jerome
On 1/23/10, Jerome Laurens
Hartmut Henkel
a écrit : Hi,
On Fri, 22 Jan 2010, Jérome Laurens wrote:
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 it must be a special viewer knowing about synctex. Couldn't one then put the required path info into the PDF file, e. g., as some special comment, or even as /PTEX_SYNCTEX_PATH key into the info dir or catalog?
Yes, my comment was a bit short. In fact, SyncTeX also works with dvi such that some equivalent to /PTEX_SYNCTEX_PATH should be defined for dvi and xdv files. Moreover, all the dvi2pdf and xdv2pdf tools should also support this kind of enhancement. It would be perfectly possible but this is not really something I'd like to do myself.
In short, my suggestion would be to somehow hard code "Factory" (or any appropriate name) as output directory name.
i guess this would make the overall system rather inflexible.
Not really. This is just a matter of convention: if someone wants to use the pdftex output directory option and does not really know what name to choose, he can simply use "Factory". That would make life easier when sharing documents as folders. And that would give a better UI experience for newcomers or beginners. Anyway, that is out of topic on this list.
Karl will be looking into the output directory option. If he thinks a default value like "Factory" would be helpful, then probably he could add that. IMO this change is backward-incompatible; until now giving no output dir means using the current dir. If we change the default to "Factory", users who don't use this option might be surprised since they will not get the output in the current dir as expected. Regards, Thanh
Sorry, ntg-pdftex is one list I'm not on, and I can't follow all the details of the problem or solution from the quote. What I can say is that it would certainly be untenable to change *tex to output anywhere except the cwd by default, if that's being suggested. Every script and user in the world expects that. Karl will be looking into the output directory option. That previous report that I said I'd look into was only about the limited question of why foo.tex and foo behave differently wrt --output-directory. Thanks, k
Le 25 janv. 2010 à 14:58, Thanh Han The a écrit :
On 1/23/10, Jerome Laurens
wrote: Not really. This is just a matter of convention: if someone wants to use the pdftex output directory option and does not really know what name to choose, he can simply use "Factory". That would make life easier when sharing documents as folders. And that would give a better UI experience for newcomers or beginners. Anyway, that is out of topic on this list.
Karl will be looking into the output directory option. If he thinks a default value like "Factory" would be helpful, then probably he could add that.
IMO this change is backward-incompatible; until now giving no output dir means using the current dir. If we change the default to "Factory", users who don't use this option might be surprised since they will not get the output in the current dir as expected.
Absolutely. This "Factory" feature should not be managed at the pdftex level, only supported eventually. In my mind, this is more an option for wrapper tools like texexec or latexmk and all the TeX frontends. However, the name "Factory" can at least be suggested as a reasonable value of --output-directory in the pdftex man page. Maybe we can go just a small step further with an optional parameter pdftex --factory foo.tex that would be equivalent to pdftex --output-directory=Factory foo.tex A wrapper tool like latexmk would support the "Factory" design as follows: the command "latexmk --factory foo.tex" would call "pdftex --output-directory=Factory foo.tex" for backwards compatibility with older pdftex versions A more clever behavior for pdftex is perfectly possible but is by no means desirable (at least IMO). For example, latexmk could guess that "Factory" should be used even if no --factory option was given, by first testing whether some Factory/foo.* file exists. This "clever" behaviour can be overriden by the --output-directory="." option. I don't know if many people would use this --factory from the command line, but the fact that it exists would suggest both users, teachers and frontend developers that it might be good practice to use it or support it. Regards Jérôme
participants (6)
-
Hartmut Henkel
-
Jerome Laurens
-
Jérome Laurens
-
Jérome Laurens
-
karl@freefriends.org
-
Thanh Han The