texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.79k stars 343 forks source link

[Feature Request] SyncTex when using --output_directory #672

Open randolf-scholz opened 5 years ago

randolf-scholz commented 5 years ago

I like to keep all the mess that are the auxiliary files in a directory called __tex__. However, I noted that synctex only works when the %.synctex.gz, %.pdf and %.tex file are all in the same directory. I was able to get it working via setting

Build & View:

txs:///compile | txs:///copy_sync | txs:///move_pdf | txs:///view | txs:///rm_sync

where

apart from that I use precompile: mkdir -p __tex__ to create the __tex__ directory and compile with pdflatex -synctex=1 -interaction=nonstopmode --output-directory=__tex__ %.tex

Now while this works it seems like quite a hassle considering that synctex allows to specify the directory of the sync file explicitly. Maybe one could simply expose synctex in the commands list as well?

sunderme commented 5 years ago

there seems no to be an easy solution as synctex itself determines the filename of the synctex file. I don't see much benefit in spending much time on cosmetics (especially as there is a clean aux files command)

dbitouze commented 5 years ago

especially as there is a clean aux files command

@sunderme This could waste time for a complex document which needs several compilations to become stable.

MeanSquaredError commented 5 years ago

Actually TexStudio (and TexLive executables) only need the .pdf and .synctex.gz to be in the same directory. The .tex file can be in a separate directory.

In my case I keep all the output files (.aux, .synctex.gz, .pdf, .log) in a separate directory. /root/texout is my output directory and I have changed the "Build & view" command to

txs:///custom_build | txs:///view (Repeat is turned off for "Build & view" command)

and then defined a custom command "custom_build:" pdflatex -synctex=1 -interaction=nonstopmode -output-directory=/root/texout %.tex (Repeat is turned on for the custom command. You will need a new version of TexStudio from GitHub since the old versions before .16 do not handle correctly Repeat for custom commands)

/root/texout is also added to "Additional search paths" for "Log file" and "PDF file"

This keeps the output files in a separate directory and also takes care of the complex tex files that need multiple compilation passes (as dbitouze mentioned).

felsenhower commented 3 years ago

I would also greatly appreciate this feature. synctex actually offers a -d parameter, so adding support for this could be done by adding an input field "Synctex file" under "Additional Search Paths" in the "Build" tab and passing this path to synctex.

The solution of @randolf-scholz doesn't seem to work perfectly on my machine, synctex only works when I don't specify the rm_sync command, so I always have the synctex.gz file in my working directory which is not ideal.

Also note that the process can be greatly accelerated by using ln instead of cp (with hard links, it's actually safe to delete the build folder).

It would actually be great if TeXstudio offered dedicated support for build directories, since "Clean auxiliary files" is a lot of hassle that isn't necessary.