I am currently using Windows 7, TeXLive2011, and TeXworks 0.4.3.
I want to put all temporary files in tmp directory located in the same working directory as the .tex file. But, I want the final .pdf file in the same directory as the .tex file, not in tmp directory.
I did the following:
pdflatex -synctex=1 -output-directory=tmp foo.tex
It put all temporary files in tmp directory, but also foo.pdf. So, I created a batch file to copy foo.pdf from tmpdirectory to the working directory.
:: %1 = tex file basename (without extension)
:: %2 = working directory
:: remove quotes in the basename tossed by TeXworks
for /f "useback tokens=*" %%a in ('%1') do set basename=%%~a
:: remove spaces in the basename tossed by TeXworks
set basename=%basename: =%
:: change / to \ in the directory name tossed by TeXworks
set dirname=%2
set dirname=%dirname:/=\%
:: create tmp directory if not exist
IF NOT EXIST %dirname%\tmp mkdir %dirname%\tmp
pdflatex -synctex=1 -output-directory=tmp %basename%.tex
:: open pdf in tmp so that synctex works in TeXworks
texworks %dirname%\tmp\%basename%.pdf
copy %dirname%\tmp\%basename%.pdf %dirname%\%basename%.pdf
But I have to open foo.pdf in tmp to make the forward/inverse search work in TeXworks. This works good enough to me, except one thing.
After executing the above batch file, TeXworks opens two windows: one for foo.tex, one for tmp\foo.pdf. Inverse search from tmp\foo.pdf to foo.tex works good, but if I do Ctrl+click in foo.tex, it opens foo.pdf, but synchronizes with tmp\foo.pdf. Of course, foo.tex does not synchronize with foo.pdf, because sync file is written for tmp\foo.pdf.
If I do not copy tmp\foo.pdf to foo.pdf in the original working directory, it works well, because there is no foo.pdf that TeXworks can open.
Would there be any workaround for this?
-aux-directory=tmpseems work only with MikTeX. Unfortunately I use TeXlive. – Chang Oct 18 '11 at 00:05