My solution for this is to use one of the latexmk engines. I then use the following latexmkrc
file in the directory with my source (.tex
) file. (You could also add this to your global ~/latexmkrc
file.):
# latexmk Init File; -*-perl-*-
$pdf_mode = 1;
$out_dir = '_build';
mkdir $out_dir;
$pdflatex = 'pdflatex --synctex=1 %O %S; cp %D .';
This will first make sure that $out_dir
(set to _build
here) exists, then will call pdflatex
with the --output-directory=_build
flag (latexmk
does this). Finally, after each call to pdflatex
, the generated .pdf
file (specified by %D
will be copied to the current directory, overwriting the local file, triggering TeXShop's previewer to reload the file. (As the original poster mentioned, creating a symlink is not enough.)
I find this behaviour of copying the generated pdf file out of the _build
directory to be useful since I usually want to keep it, even when deleting all of the auxilliary files (which is just done by deleting the _build
directory).
By including the following comment
% !TEX TS-program = pdflatexmk
at the top of your source (.tex
) file, you can ensure that TeXShop will use the pdflatexmk
engine by default.
The advantage of this approach is that by distributing the latexmkrc
file with your .tex
file, everything will "just work"* for someone using TeXShop – even if they forget to select the pdflatexmk
engine.
* This will "just work" if TeXShop was installed at version 3.07 or later. Otherwise, you will need to (have your colleagues) copy the inactive pdflatexmk.engine
file to the active engine directory (note: ~/Library/
is the Library
folder in the $HOME
folder, not the system /Library
folder):
cp ~/Library/TeXShop/Engines/Inactive/Latexmk/pdflatexmk.engine ~/Library/TeXShop/Engines/
See Also
--output-dir=/tmp
and then creates a copy (or a symbolic link) of the output pdf to the original directory (where your source file is). – Corentin Aug 15 '12 at 10:26open -a TeXShop /tmp/file.pdf
at the end of your script. – Corentin Aug 15 '12 at 17:49