When asked to "Trash Aux Files” after typesetting a Beamer presentation, TeXShop does not remove .nav and .snm.

Is there a way to tell TeXShop to remove those files as well?

Is there a user-editable list of the aux files that TeXShop removes?

  • I use script written by Claus Gerhardt. The script can be found here: Deleting external/auxiliary files?. This allows you to add any type of file extension you want to the list.
    – Alan Munn
    Jan 15, 2014 at 1:54
  • Unfortunately, the list of aux files seems to be hard-coded in TeXShop. See the method trashAUX in TSDocument.m.
    – lhf
    Jan 15, 2014 at 9:32
  • 1
    The list is not hard coded. There is a 'hidden preference' (but documented) that can allow you to add new extensions provided they are just with a single ..
    – Alan Munn
    Jan 15, 2014 at 16:48

1 Answer 1


TeXShop has a hidden preference that allows you to add a limited range of new extensions to the list of trashed .aux files. The only restriction is that the preference assumes that the extension is a single string prefixed with a ., so e.g. you can add the extension .foo, but not the extension .foo.bar. Because of this restriction, I prefer to use an Applescript which allows me to add any kind of extension I like. I'll describe both method here.

Hidden preference method

To add an extension .foo to the list of trashed aux files, open a Terminal window and enter the following:

defaults write TeXShop OtherTrashExtensions -array-add "foo"

So in your particular example you can type:

defaults write TeXShop OtherTrashExtensions -array-add "nav"
defaults write TeXShop OtherTrashExtensions -array-add "snm"

As noted above, this will only work for extensions of the form .foo, not foo.bar.

Applescript method

A more general method is to use the following Applescript (first described in this answer:).

Open the Macro Editor in TeXShop and make a new Macro with the following Applescript: (this trashes the extension that I usually want trashed, including some latexmk and biblatex extensions. Adjust as needed.

-- Apply only to an already saved file
-- Claus Gerhardt, September 2006
(*This script gets the path of the frontmost (tex) document in TeXShop and removes the corresponding auxilary files the suffixes of which are listed in the list L. Beware of the quotation marks. The list L may contain suffixes to which no corresponding files exist.*)

my remove_auxiliaries()
on remove_auxiliaries()
    set L to {".aux", ".synctex.gz", ".fdb_latexmk", ".out", ".toc", ".bbl", ".blg",
              ".ind", ".sind", ".run.xml","-blx.bib",".log", ".end", ".1", ".nav",
              ".snm"} as list

    tell application "TeXShop"
        get path of document of window 1
        set fileName to result
    end tell

    set {baseName, texName, pdfName, namePath, dirName, dirNameunquoted, logName, logPath, rtfName, docName} to my setnamebbedit_rootn(fileName)


tell application "TeXShop"
    close document docName
end tell

    repeat with x in L
            set shellScript to "cd " & dirName & ";"
            set shellScript to shellScript & "rm -f  " & baseName &  x
            do shell script shellScript
        end try
    end repeat

end remove_auxiliaries

on setnamebbedit_rootn(x)
    set n to (number of characters of contents of x)
    set fileNamequoted to quoted form of x
    set windowName to do shell script "basename " & fileNamequoted
    set m to (number of characters of contents of windowName)
    set dirName to quoted form of (characters 1 thru (n - m - 1) of x as string)
    set dirNameunquoted to (characters 1 thru (n - m - 1) of x as string)
    set theText to contents of windowName as string

    set n to (number of characters of contents of theText)
    set i to n as number

    repeat while i > 0
        if character i of theText is equal to "." then
            set m to i
            exit repeat
            set i to (i - 1)
        end if
    end repeat

    set baseName to (characters 1 thru (m - 1) of theText as string)
    set texName to baseName & ".tex"
    set namePath to dirNameunquoted & "/" & baseName as string
    set pdfName to namePath & ".pdf" as string
    set rtfName to namePath & ".rtf" as string
    set logPath to namePath & ".log" as string
    set logName to baseName & ".log" as string

    set theFile to POSIX file x as string
    tell application "Finder"
        get displayed name of the file theFile
    end tell
    set docName to result

    return {baseName, texName, pdfName, namePath, dirName, dirNameunquoted, logName, logPath, rtfName, docName} as list
end setnamebbedit_rootn

The list of extensions is modifiable in set L to ... line near the beginning of the script. Here, unlike the TeXShop defaults method, you specify the entire extension, including the . which allows extensions of the form .foo.bar to be specified as well.

  • Missed that hidden preference. Works perfectly. Thanks!
    – lhf
    Jan 15, 2014 at 19:15
  • Hi, in general, how can trashing Aux Files help with compiling? Today I tried compiling and it came up with an error which stopped it from compiling properly, but then I trashed Aux Files and the next compile had no issues. Why did that happen>
    – user71207
    Jun 21, 2021 at 12:18
  • 1
    @user71207 Aux files can get corrupted by incomplete runs that stop for other reasons and then when the aux file is read cause errors. See Will cruft from a previous compile ever change the final look of my document for some more discussion.
    – Alan Munn
    Jun 22, 2021 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .