[Tex/LaTex] Change the path where (the internal viewer of) TexStudio looks for the generated PDF file

texstudio

I've changed almost all TextStudio commands to generate temporary files into a different build directory. I need this behavior because I'm syncing the source directory with the cloud and this way I can avoid unnecessary network activity (temp files sync). All works fine and the directory containing the .tex files remains clean.

However the internal PDF viewer doesn't work anymore. It still looks for the PDF in the same directory where the original .tex file is located.

Is there any wat to setup the internal viewer to look into the build folder?

Best Answer

Similar to "Cursor on build error and temp build directory with TexStudio".

In TexStudio 2.5.2 on Linux the "PDF Viewer" path under "Additional Search Paths" does not seem to actually set the path. In my case, the newly-set output directory was not being passed to dvips or the viewer, resulting in the error:

Process started: dvips -o "filename".ps "filename".dvi
...
dvips: DVI file can't be opened: filename.dvi: No such file or directory
Process exited with error(s)

This can be solved by setting the paths manually. For example, if you were setting your directory to "/tmp":

Under Options -> Configure -> Commands

# Set the output directory with -output-directory
latex -src -interaction=nonstopmode -output-directory=/tmp %.tex
DVI Viewer: evince /tmp/%.dvi > /dev/null
PS Viewer: evince /tmp/%.ps > /dev/null
PDF Viewer: evince /tmp/%.pdf > /dev/null
dvips -o /tmp/%.ps /tmp/%.dvi

Under Build -> Additional Search Paths (to remove a log file error)

Log File: /tmp

I tried setting search paths, -aux-directory, etc. and manually setting the path as so was the only thing that worked for me.