[OS X TeX] Open Selection -- Applescript for TeXShop/iTeXMac
Matthew Hills
hills_tex at tina.stanford.edu
Sat Oct 16 01:29:53 CEST 2004
Claus, thanks for forwarding the scripts you use with BBEdit.
I put together a script to open a file based upon the current text
selected in TeXShop or iTeXMac.
http://tina.stanford.edu/~hills/Tidbits/
The behavior is similar to the "Open selection" menu item in iTeXMac,
except that the file extension is not required. e.g., you can select
"report" in "\documentclass[12pt]{report}" and the script will open
"report.cls" from the teTeX search path.
If the file extension is not specified, the script looks for the text
just before the selection to try and find tell-tale tags like
"\bibliographystyle" that would suggest what file extension to use
(".bst" in this case). I welcome any feedback on suggestions for how
to expand the list of important tags (I currently have \includeonly,
\include, \input, \bibliographystyle, \bibliography, \usepackage,
\documentclass, and \includegraphics).
Also, I put in a hack to help me with opening files that exist outside
the teTeX tree. For example, I keep all my figures for a document as
PDFs in a subdirectory of my document directory named "./figs".
Secondly, I define my own latex macro to set the graphics (this is an
example, mine is much uglier):
\newcommand{\myfig}[1]{ \includegraphics{figs/#1}}
Then I could add a record to the file_extension_map property of the
script:
{tag:"\\myfig", extension:".pdf", prefix:"figs/"},
So that selecting "smiley" in "\myfig{smiley}" would then be able to
open a window to show "./figs/smiley.pdf"
As always, let me know of any suggestions, or you find any errors (I
really appreciated Will's suggestion to use kpsewhich for my earlier
scripting endeavors for bibliographic citations, and I also appreciated
error reports that uncovered faulty assumptions I was making based upon
how I structure documents in latex...).
Matt
--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
& FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
More information about the macostex-archives
mailing list