I'd like to enhance the pdflatexmk engine to delete the files afterwards. I'm coming from Automatically "Trash Aux Files" after successful typesetting in TeXShop, where the instruction is to write a Python file that does execute "pdftex", and then delete every other file ex-post.
However, I'm unaware in how I may call different texshop "engines". That is, instead of doing
command = '/usr/texbin/pdflatex ' + '--output-driver=/usr/texbin/xdvipdfmx ' + OUTPUT_ARGUMENT + '"' + output_dir + '"' + ' ' + '"' + pdf_path + os.path.sep + tex_file + '"'
Since I'm saving my file in the /Engine
folder, I thought I could simply
execfile("pdflatexmk.engine")
instead – But this gives
Traceback (most recent call last):
File "/Volumes/Stuff/user/Library/TeXShop/Engines/pdflatexmk_del.py", line 43, in <module>
execfile("pdflatexmk.engine")
IOError: [Errno 2] No such file or directory: 'pdflatexmk.engine'
Best Answer
Each engine is a shell script of its own, so probably the cleanest method to augment an existing engine is to add to the script.
What you want is to effectively call
pdflatexmk -c
after each successful run ofpdflatexmk
.If you look at
pdflatexmk.engine
you'll see that the last line is:That's the nut of the whole script: calling
latexmk
. To add commands that are executed only on successful completion of this line, add&& <cmds>
. So change the last line to:Save that new engine as
pdflatexmk-c.engine
or something else you like, and restart TeXShop.Then you can invoke this engine as the first line in your
.tex
file, as in:You'll see that
pdflatexmk
is run, runningpdflatex
a few times to get the generated references right, and thenpdflatexmk -c
is run, deleting the auxiliary files.