当在排版 Beamer 演示文稿后被要求“删除辅助文件”时,TeXShop 不会.nav
删除.snm
。
有没有办法告诉 TeXShop 也删除这些文件?
TeXShop 删除的辅助文件是否有用户可编辑的列表?
答案1
TeXShop 有一个隐藏的首选项,允许您将有限范围的新扩展名添加到已删除文件列表中.aux
。唯一的限制是首选项假定扩展名是一个以 为前缀的单个字符串.
,因此例如您可以添加扩展名.foo
,但不能添加扩展名.foo.bar
。由于这个限制,我更喜欢使用 Applescript,它允许我添加任何我喜欢的扩展名。我将在这里描述这两种方法。
隐藏偏好法
要将扩展名添加.foo
到已删除的辅助文件列表,请打开终端窗口并输入以下内容:
defaults write TeXShop OtherTrashExtensions -array-add "foo"
因此,在您的特定示例中,您可以输入:
defaults write TeXShop OtherTrashExtensions -array-add "nav"
defaults write TeXShop OtherTrashExtensions -array-add "snm"
如上所述,这仅适用于 形式的扩展.foo
,而不是foo.bar
。
Applescript 方法
更通用的方法是使用以下 Applescript(首先描述于这个答案:)。
在 TeXShop 中打开宏编辑器并使用以下 Applescript 创建一个新宏:(这会丢弃我通常想要丢弃的扩展,包括一些latexmk
扩展biblatex
。根据需要进行调整。
--AppleScript
-- 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
try
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
else
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
扩展列表可在set L to ...
脚本开头附近进行修改。与 TeXShop 默认方法不同,您可以在此处指定整个扩展,包括允许指定.
格式扩展的扩展。.foo.bar