Ramón's TeXShop Tools

The following are a few of applescripts and related tools that I wrote that might be useful when typing a document in TeXShop, which is a very nice front end for LaTeX on Mac Os X. They were tested with TeXShop version 2.26, on Mac Os X 10.5.6. Some of these Macros are as of version 2.26 part of TeXShop Big Grin (the versions in this page might be newer).

NOTE: some of the scripts and software below break with OS X 10.6 (Snow Leopard). I have fixes for some of them and will update the site during the summer 2010. In the meanwhile write me if you have difficulties.

To use one of them select "Open Macro Editor…" from the "Macro" menu in TeXShop and create a new macro (assign each a key combination if you wish). Paste the text of the macros, which you can copy directly from your browser after clicking on "view source" below (for an easy way to install all of the TeXShop scripts at once see below).

  1. Close Begin/End 1.0 [view source]
    This script will close a TeX Begin/End environment. It will handle nested Begin/End environments correctly, and knows if an environment is already closed.
    For example, if an environment starts with \begin{equation*}, then an invocation of the script will close it with \end{equation*}.
  2. Insert Begin/End 1.0 [view source]
    One of the default TeXShop macros, called Begin/End, inserts an Begin/End environment, where the environment name is taken from the current selection. That entails having to type the environment name, select it and then invoke the macro. This script auto selects the environment name (the cursor can be anywhere from the beginning to the end of the word). It also does a better job of handling the situations when the environment name is at the beginning, end or the middle of a line.
  3. Program 1.2 [view source]
    This script improves on the old TeXShop default macro called "Program", i.e., % !TEX TS-program = #INS#, It assumes that engines are installed in ~/Library/TeXShop/Engines/
    (The default engine, if present, is "pdflatexmk", this can be changed by editing the beginning of the script)
  4. Encoding 1.2 [view source]
    Does for "Encoding" the same as the above script does for "Program"
    (The default encoding, if present, is "MacOSRoman", this can be changed by editing the beginning of the script)
  5. Root 1.1 [view source]
    Does for "Root" the same as the above two scripts do for "Program" and "Encoding".
    It has the nice feature of letting the user choose between an absolute or a relative path to the root document (it uses Perl to accomplish this).
  6. Format 1.0 [view source]
    This script adds a format specification to the document, e.g. %&pdflatex in the first line, by letting the user choose which format she/he wants to use. For example, Claus Gerhardt's excellent Flashmode uses these format specifications to know which method to use in typesetting. Its behavior can be customized by means of setting four different properties in the preamble of the script. For example, if the user wants it to search for all available formats set few to false and then only the formats in short_list will be used. For this to work the path to kpsewhich has to be in the variable PATH of the ~/.MacOSX/environment.plist or one must set the path to it in the script's kpsewhich_path property (currently set to /usr/texbin/kpsewhich). Notice, that one can get the path to kpsewhich by typing which kpsewhich in the Terminal. The script tries to do this but if the environment.plist's PATH is not set to include the paths to the TeX executables it will fail (the environmental variables and their values available to applications are different to those available to the shell, e.g. typing echo $PATH in the Terminal, and running do shell script "echo $PATH" in the Script Editor can yield different results. The preference pane RCEnvironment is a nice way to manage and explore environment.plist). There is an ingenious way of avoiding all this grief, download and install the TeX Distribution pane and TeX Distribution Helper (if you use TeXLive 2008 or gwTeX you may already have it installed, look in your System Preferences), using it will allow /usr/texbin to work with various installations.
  7. TeXCount 1.1 [view source]
    Invokes the TeXCount perl script, which it assumes is located at "/usr/texbin/texcount" to give some statistics for the front document. TeXCount is installed as part of MacTeX-2008.
  8. TeXCount to PDF or HTML 1.1 [view source]
    Invokes TeXCount to generate a full report that gets converted from HTML to a PDF that is then opened with TeXShop. Can be easily modified, by changing the property pdf to false in the script, so that it just generates an HTML file that gets opened by the default browser.
  9. TeXShop to BBEdit 1.0 [view source] and BBEdit to TeXShop 1.0 [view source]
    These scripts transfer a document back and forth between TeXShop and BBEdit preserving the current selection. To install BBEdit to TeXShop place it in BBEdit's Scripts folder (the easiest way to get to this folder is to go to BBEdit's Script menu and choose "Open Scripts Folder") or a sub folder of it. See BBEdit's manual for information on its Script Palette and Script Menu.
  10. TeXShop to RPN2TeX 1.1 [view source] and RPN2TeX to TeXShop 1.1 [view source]
    Wataru Maeda's RPN2TeX is a beautifully implemented and unique LateX equation editor (if you are using TeXLive you must change the paths in the preferences to /usr/texbin/). These are two scripts that integrate TeXShop and RPN2TeX. I assigned to the TeXShop to RPN2TeX Macro in TeXShop the F1 function key (via the System Preferences' Keyboard & Mouse panel, as TeXShop allows little else aside from alpha numeric assignments as shortcuts from its Macro Editor). I invoke RPN2TeX to TeXShop using the same F1 function key by pasting it inside an Applescript Smart Item in Peter Maurer's Butler (make sure to restrict the script to only work when RPN2TeX is the front application). As RPN2TeX has no Applescript support of its own I use UI Scripting. These scripts were tested with RPN2TeX 0.8.
  11. TeXShop to LaTeXiT 1.1 [view source] and LaTeXiT to TeXShop 1.0.1 [view source]
    Two way integration for LaTeXiT and TeXShop. Tested with LaTeXiT 1.16.1.
  12. TeXShop to TeX FoG 1.1 [view source] and TeX FoG to TeXShop 1.1 [view source]
    Two way integration for TeX FoG and TeXShop. Tested with TeX FoG 1.2.4 (recompiled from source to run natively on an Intel processor) and 1.3. Note: TeX FoG to TeXShop is now redundant as, among other things, TeX FoG 1.3 adds the capability to communicate with TeXShop (it uses the clipboard, whereas this script does not).
  13. Insert File Path 1.0 [view source]
    Script that inserts \input{•}, \include{•} or \includegraphics[]{•}, where • is either a relative or an absolute path to a file the user chooses. It tries to be smart about spaces in file paths (most likely an impossible task, so this feature can be turned off; see below). Beware that for \include{•} the path • can only be to the directory of the target document or a subdirectory thereof. Therefore, if an \include{•} is impossible, no choice will be presented, and an \input{•} will be automatically entered. This might be confusing to a user that does not know of this limitation.
    It is customizable by setting the values of "properties" at the beginning of the script:
  14. Now, for my personal use I like to have the possibility of spaces in file names (no_spaces: false), no absolute paths (absolute:false), I like to limit the kinds of graphic files it can handle (ignore_suffix:false), and to suppress suffixes in graphics files (use_suffix:false).
  15. Check LaTeX Begin-End Pairs 1.0
    Invokes the Check LaTeX Begin-End Pairs program to check for mismatched parentheses, brackets, begin-end blocks, etc., in the selection of the current front most window in TeXShop. Requires CocoaDialog (not included, so download it) in an Applications folder (the system one or your personal one), and the supplied checktex executable to be in "~/Library/TeXShop/bin" directory (you may need to recompile it, so the source, tweaked to work in OS X, and instructions are included). Download it here. A droplet that accomplishes the same for TeX documents dropped on it can be found below.

Quick Install

A quick way to install most of the TeXShop scripts found here at the same time (note that BBEdit to TeXShop is a BBEdit script and RPN2TeX to TeXShop is an RPN2TeX script) is described in the TeXShop manual: "[t]o add macros created by others to your list of macros, open the Macro Editor and choose 'Add macros from file...'. Then use the Macro Editor to arrange the macros as you desire." Do this with the plist file found here (does not include Check LaTeX Begin-End Pairs).

Related Stuff

  1. New window for Flashmode.
    I like to use Flashmode for TeXShop by Claus Gerhardt; however due to my poor eyesight I use a low resolution on my monitor (a large wide screen TV). So the window he designed is too big for me to use. So I modified the nib file to make everything very compact. You might find it useful when using Flashmode on a laptop. Download MainMenu.nib here and install it by control clicking (right click) on the Flashmode application in the Finder and select Show Package Content in the context menu and replace the existing MainMenu.nib in /Contents/Resources/English.lproj/. Here is a preview.
  2. LaTable (for OS X, Intel only)
    Here is a table editor, LaTable by Alex A. Denisov, for LaTeX, which was made for Win32. I added an icon and a launcher application. To use it you need Darwine, which lets you run many windows applications on an Intel Mac for FREE (tested with version 1.1.18). I would also update X11 with the latest XQuartz. Double click LaTable (not LaTable.exe) to launch. You need a chm viewer, say iChm, to read the documentation. Here is a preview.
  3. Startup Items and Shutdown Items folders 1.1
    The BBEdit text editor has among its plethora of features Startup Items and Shutdown Items folders in the ~/Library/ApplicationSupport/BBEdit folder. For example, any applescript in the StartupItems folder gets executed upon BBEdit launching and any other kind of file, folder or application there gets opened. Now, such features can be implemented (with some caveats) with a preference pane called Do Something When and Applescript applications you can find here with examples (for TeXShop, but easily modifiable for any application) and detailed instructions.
  4. Drop RTF2LaTeX2e 1.0
    Here is RTF2LaTeX2e 1.0fc1 bundled as a droplet. The pref folder must be in the same directory as the application. I edited r2l-pref to my liking (e.g., use tabular instead of longtable for tables, use colors, and applemac for the font conversion).
  5. JasTeX 1.1 a program for drawing Graphs and Automata in LaTeX
    Here is JasTeX 1.1 (a GUI for GasTeX) bundled as an OS X application. The code was tweaked a little bit to meet my needs, for example, the LaTeX code it generates now suppresses page numbers and includes a TeXShop program directive that calls an engine called jastex.engine (which is included and generates a cropped PDF). A (poor, perhaps atrocious) translation of the French manual into English is also included. To install JasTeX copy the eponymous folder wherever you want. To install the jastex.engine place it in ~/Library/TeXShop/Engines/. NOTE: write me if you need a Snow Leopard version.
  6. DeTeXor 2.7
    Here is DeTeXor a user configurable droplet (drop onto the icon on the Finder not its window; the application must not be already running) that finds and cleans the garbage that is the byproduct of compiling a TeX file. It moves to the trash (does not delete) the files associated to an existing TeX file. For example, it will only trash foo.aux if you set it to trash files with that suffix, if foo.tex lives in the same directory, or a subdirectory of it, and if you have permission to delete files in the that directory. However, be careful, since it trashes files please exercise caution when using it (do not drop on it folders and files you do not want it to process). Please read the enclosed instructions!
  7. Drop Check LaTeX Begin-End Pairs 1.1
    Here is a droplet that runs the Check LaTeX Begin-End Pairs command line program on all the TeX files dropped on it. It can be very useful if you cannot find a missing parenthesis. You can find a TeXShop version above.
  8. Drop Changebar 1.0
    Here is a droplet that runs the command line program chbar.sh (included with the changebar package, used to "add changebars to a LaTeX document") on a pair of LaTeX files dropped on it. Inspired on Herb Schultz's droplatexdiff (which gives better results, by far,, but can choke if the changes are very substantial).
  9. Mark Section TeX 1.0
    Here is a droplet that runs Blake Hannaford's perl script sectex.pl, which inserts comments into your latex source indicating figure and section numbers by each figure and section of the LaTeX files dropped on it.
  10. Drop Canonify Labels 1.0
    Here is a droplet that runs Georg Lang's perl script canonify_labels.pl (the original site is unavailable; but archive.org has a copy). The original site described it as "a perl script to update and canonify the labels of your latex document, changing all reference commands accordingly."
  11. Drop LaTeX2RTF 1.0
    Here is a droplet that runs LaTeX2RTF on the TeX files dropped on it (note: if TextEdit does not open the resulting files then try Microsoft Word, NeoOffice or OpenOffice).
  12. LaTeXMe 1.0
    Here are detailed instructions and scripts on how to work with LaTeX on an iPad. They require an editor on the iPad, and there is one that is great: TeX Touch, which has built in support for LateXMe.
  13. Adobe Acrobat Pro and Adobe Reader Texshop Engines 1.0
    Here are two engines for using Adobe Acrobat Pro (tested with version 9.0.0) and Adobe Reader (tested with version 9.3.2) to preview PDF's created with TeXShop. To install them place them in "~/Library/TeXShop/Engines", and make sure they are executable. To use the Acrobat engine place the line "% !TEX TS-program = Acrobat-Preview" (no quotes, of course) at the beginning of your LaTeX file (among the first 20 lines), then Typeset. For the Reader engine similarly use "% !TEX TS-program = Reader-Preview". Both engines are setup to use Herb Schultz's pdflatexmk engine, so you have to modify them if you have a different preference. Moreover, both engines require that in TeXShop's preferences you have "[a]ll windows start at fixed position" (when you set this you must quit and relaunch TeXShop so that it updates its preferences on disk). The Adobe Acrobat Pro Engine, remembers the window position and dimensions, and the page the document was in between different runs. The Adobe Reader Engine is more limited and it requires that you open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane.
  14. ChkTeX for TeXShop 1.4
    Here is an application that provides a GUI interface for ChkTeX in TeXShop. Here is a screen shot. The included Read Me has detailed instructions. You must download TeXShop Webpage Helper, which is not bundled with ChkTeX for TeXShop.
  15. TeXShop Webpage Helper 2.0
    Here is a handler for the protocol (scheme name) “texshop://”. It allows you to have hyperlinks in web pages that when clicked launch TeXShop (in the foreground or background as indicated), open the indicated TeX document in TeXShop, which scrolls to the given line and makes the given selection. Additionally, since version 2.0, you can send editing commands to TeXShop by clicking on links. It will not typeset documents! If you double click the application it will do nothing. The folder named TeXShop Webpage Helper must (with its contents) be in the Applications folder (/Applications) for the examples in the manual to work. Only one copy of TeXShop Webpage Helper should exist in your computer (ChkTeX for TeXShop version 1.3.5 and lower had a copy inside the application bundle, so you must update ChkTeX for TeXShop too)! Here is a clip of TeXShop Webpage Helper in action with a hyperlinked version of George Grätzer's Math Symbols Table (his table is now an equation editor).
  16. HTML Console Prototype 1.0
    Here is a working prototype of a replacement console for TeXShop. It showcases what could be done if TeXShop's console was a WebKit window and the user could replace or improve the parser for it, which was written on a scripting language of her choice.
  17. Tiny Browser 1.3.1
    Here is an application that provides a WebKit window to which you can pipe shell commands, from scripts and the Terminal, and display them using HTML (it can also display PDFs). It is an example, which includes all sources, of how to build Web Page application using Platypus (including a solution to the problem of positioning and resizing Platypus' windows). Double click it and you will get the manual displayed on its window.
  18. TeXor 1.0.2
    Here is a batch typesetter for TeXShop: drag and drop TeX documents onto its icon on the Finder and it will typeset all of them according to the TeXShop engine defined in each document with the % !TEX TS-program tag (see TeXShop's help for an explanation of what this is), presenting you with a console with all the results. If additionally, you have TeXShop Webpage Helper installed, then the hyperlinks in the TeXor Console will point to the lines containing the errors.

License

These scripts are free software; you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

These scripts are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Copyright

Copyright ©2007-2009 Ramón M. Figueroa-Centeno. All Rights Reserved.

37235

Page updated: Saturday, March 17, 2012 9:17 AM HST