Skip to content
nathan11g edited this page Jun 15, 2012 · 6 revisions

Scripts

Scripts are by Nathan Grigg, unless otherwise noted.

Typeset

Typesets your Latex document and open the pdf file.

By default, the script uses [Skim][1] to view the pdf, falling back to Preview.app if Skim is not installed. You can also specify a custom pdf viewer by editing the script. The script looks for Latex executables in /usr/texbin, which is where [MacTeX][2] installs them by default. If necessary, you can change these defaults by editing the beginning of the script.

Usually, the script uses pdflatex to typeset your document, but this can be changed by including a program directive at the beginning of your document. If you are using multiple files to organize your Latex markup, you can also use a root directive. These directives should have the following form:

% !TEX program = xelatex
% !TEX root = main.tex

If there is a typesetting error, the script will try to take you to the place in your document where the error occurred. For this, the script searches through the log file using code from the [rubber][3] project by Emmanuel Beffara.

When using Skim to preview, the script will work best if you deselect "Check for file changes" in Skim's preferences.

Open pdf

Open the pdf file corresponding to your Latex document.

By default, the script uses [Skim][1] and tries to find the place in the pdf that corresponds to your current cursor position in the Latex file. If Skim is not installed, it will open the file using Preview.app. You can change the viewer by editing the first lines of the script.

Change environment

Change both the begin and end command of the current environment.

This script detects the environment that contains the cursor and prompts for a new name.

Star-unstar environment

Add or remove a star from the name of the current environment.

If the name of environment that contains the cursor ends in a star, the star is removed. Otherwise, a star is added to the environment name.

Show log warnings and errors

Display warnings and errors from the log.

This script uses code from the [rubber][3] project to parse the log file, and uses BBEdit to display the results in a unser-friendly manner.

Check Latex Semantics

Run [ChkTeX][4] and display the results in a BBEdit results browser.

[ChkTeX][4] is Lint for Latex. This Applescript is written by Ramón M. Figueroa-Centeno, and uses BBEdit to interface with the ChkTeX output in a user-friendly manner. You need to have ChkTeX installed for this to work. ChkTeX is included in the MacTeX package.

Declare Math Operator

Insert \DeclareMathOperator command in preamble of document.

Tex Documentation Lookup

Display documentation for a package, using texdoc.

Typeset inserting git info

Insert git info into the document before typesetting.

If the document is part of a git repository, this script defines a command \RevisionInfo that prints the current git revision information. It then typsets the document and then deletes the command.

To make this useful to you, you will need to put the \RevisionInfo command somewhere in your document (e.g. in a header or watermark). Furthermore, you should include \providecommand{\RevisionInfo}{} in the preamble, which will cause \RevisionInfo to be blank unless otherwise defined.

The idea is that when you usually typeset, the info will not be printed. Only under certain circumstances (e.g. you are going to print it out or email it to someone) do you want to include the revision information. One benefit to this method is that if someone else needs to typeset the document and they do not have the full git repository or even know what git is, everything will work. [1]: http://skim-app.sourceforge.net/ [2]: http://www.tug.org/mactex/ [3]: https://launchpad.net/rubber/ [4]: http://baruch.ev-en.org/proj/chktex/

Clone this wiki locally