[OS X TeX] AppleScript for the use of nomenclature in TeXShop

Thomas Schröder hydrochlorix at gmx.net
Wed Mar 31 10:05:00 EST 2004

Hi everybody,

I wipped up a small TeXShop AppleScript for the use of the very nice 
nomenclature package that was mentioned here a couple of times. In case 
one of you missed it, the nomenclature package enables you to easily 
set up a nomenclature for all of your symbols and/or a list of 
abbreviations. It does so by creating a *.glo file which has to be run 
with makeindex. The thing is that you can't (well, I couldn't anyway) 
use the makeindex menu option from within TeXShop because that menu 
option expects a *.idx file instead of a *.glo file and because you 
must also load nomenclature's own makeindex style file to get 
everything right. This is where my little AppleScript comes in. It is 
heavily based on Claus Gerhardt's AppleScripts for TeXShop, so my 
thanks go to you Claus (and Dick, of course)!

What it does is, it gets the name of the opened file, runs makeindex on 
the *.glo file that was produced with nomenclature's help from a 
previous latex run and produces a *.gls file that will be read by 
nomenclature on subsequent latex runs. When it is finished it will open 
makeindex's log file at your convenience.

So, without further ado, here's the script:

---------Begin Script

-- Apply only to an already saved file
-- Claus Gerhardt, Nov. 2003

set scriptPath to (do shell script "dirname " & 
set scriptPath to scriptPath & "/setname.scpt"
set scriptName to POSIX file scriptPath as alias
set scriptLiB to (load script scriptName)
tell scriptLib
set frontName to setname(#NAMEPATH#,#TEXPATH#)
end tell

set fileName to  #NAMEPATH#
set n to (number of characters of contents of fileName)
set fileNamequoted to quoted form of fileName
set baseName to do shell script "basename " & fileNamequoted
set m to (number of characters of contents of baseName)
set dirName to quoted form of (characters 1 thru (n - m - 1) of 
fileName as string)
set texName to baseName & ".tex"
set gloName to baseName & ".glo"
set glsName to baseName & ".gls"

set shellScript to "cd " & dirName & ";"
-- the next part should be on one line, I think
set shellScript to shellScript & 
"/usr/local/teTeX/bin/powerpc-apple-darwin-current/makeindex  " & 
gloName & " -o " & glsName & " -s  
-- end of one line
do shell script shellScript

set fileLog to fileName & ".ilg"
set theFile to alias (POSIX file fileLog)
set logName to baseName &".ilg"

tell application "TeXShop"
open theFile
end tell

---------End Script

Unfortunately, I had to use absolute paths for makeindex and 
nomenclature's style file, but other than that it has been working 
nicely over here. To use it, open TeXShop's macro editor, create a new 
macro, give it a nice name and paste in the above macro (possibly from 
a big window in Mail, so as not to mess up the line breaks, I guess).

I thought this might be useful for others, so here you go. Hints on how 
to do this in a better way are much appreciated :-)

     Ciao, Thomas

Thomas Schröder +++ hydrochlorix at gmx.net
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.

More information about the MacOSX-TeX mailing list