Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there some way to automatically fire the "Trash Aux Files" command after successful typesetting in TeXShop, without manual action on the part of the user?

share|improve this question
4  
What is successful typesetting? Sometimes LaTeX needs to know what is in those files for correct placement (tikz) and numeration (label/ref). –  A.Ellett Dec 29 '12 at 0:50
1  
add comment

2 Answers 2

up vote 1 down vote accepted

Though there may well be a cleaner method that I am not aware of, I have found that the following serves the same function. Note that the following will process the document using XeLaTeX, but can be customized to suit.

In the ~/Library/TeXShop/Engines directory, create a python script, such as XeLaTeX.py, with the following contents:

# -*- coding: utf-8 -*-
import os, sys
tex_file = sys.argv[-1]
os.system("xelatex --shell-escape " + tex_file)
if os.path.isfile(os.path.splitext(os.path.basename(tex_file))[0] + ".aux"):
  os.remove(os.path.splitext(os.path.basename(tex_file))[0] + ".aux")
if os.path.isfile(os.path.splitext(os.path.basename(tex_file))[0] + ".log"):
  os.remove(os.path.splitext(os.path.basename(tex_file))[0] + ".log")
if os.path.isfile(os.path.splitext(os.path.basename(tex_file))[0] + ".out"):
  os.remove(os.path.splitext(os.path.basename(tex_file))[0] + ".out")
if os.path.isfile(os.path.splitext(os.path.basename(tex_file))[0] + ".synctex.gz"):
  os.remove(os.path.splitext(os.path.basename(tex_file))[0] + ".synctex.gz")
print(os.path.splitext(os.path.basename(tex_file))[0])

Next, instruct TeXShop to use this file. One way of doing so is, in the Engine tab of the TeXShop Preferences, to edit the command line instruction for Latex under pdfTeX to read:

/usr/bin/python /Users/USERNAME/Library/TeXShop/Engines/XeLaTeX.py

Now, after processing a file using the LaTeX command, the .aux, .log, and .synctex.gz files will all be automatically deleted; the script can be easily edited to delete any other files also.

Lastly, as noted in the comments to the original question, this can cause problems if these files must be referred to again, and the script should not be used in such cases.

share|improve this answer
    
To add this this wondeful answer, also check out gist.github.com/macmadness86/5269856 –  macmadness86 Mar 31 '13 at 11:23
add comment

In addition to Кигава Енсеи's answer for typesetting with the xelatex engine, below minor alteration works perfectly in TeXShop using pdflatex for typesetting

Just change xelatex' topdflatex' and it will work

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.