LaTeX and PDFView

PDFView offers powerful integration with LaTeX:

Setting up your editor

With the use of PDFSync, you can have PDFView load the document, and jump to the corresponding page of the line you are editing in your editor. To do it, all you have to do is set up your editor to call this script: %line "%pdffile"

One thing is to be noticed: %pdffile must be the full path of the PDF document - e.g. /Users/andry/work/test.pdf is fine, where ~/job.pdf is not.

Setting up TextMate

For TextMate, you can open up the Bundle Editor (Control+Option+Command+B), select LaTeX and create (or replace the TeXniscope one) a new item, calling it (for example) "Show in PDFView (pdfsync)". Insert the following as the commands:


# Switch to the right directory
cd "$(dirname "$TM_LATEX_MASTER")"


if [[ -x "$SCRIPT" ]]; then
	"$SCRIPT" &>/dev/console "$TM_LINE_NUMBER" "${FILE%.tex}.pdf"
	open -a
	echo "Unable to locate PDFView."

Your new command should look similar to this screenshot:

TextMate setup

Setting up Emacs

The following code may require a newer version of Emacs and AUCTeX, it was tested using Emacs version and AUCTeX 11.84, all contained in Carbon Emacs build from Spring 2007

Inverse search

You need to put the following code in your .emacs

		;; Starts the Emacs server

In addition, most people would want to make Emacs auto-raise when a CMD + Click is executed in PDFView. Carbon Emacs does not seem to respond to raise-frame, so we do it using Applescript.

		(defun raise-emacs-on-aqua() 
		    (shell-command "osascript -e 'tell application \"Emacs\" to activate' &"))
		(add-hook 'server-switch-hook 'raise-emacs-on-aqua)

The ampersand after activate makes the command slightly more robust, but also opens up an *Async Shell Command*. You may experiment with removing it.

Forward Search

To make PDFView jump to the relevant line of the LaTeX source, you can add the following to your .emacs

		;; The following only works with AUCTeX loaded
		(require 'tex-site)
		(add-hook 'TeX-mode-hook
		    (lambda ()
		        (add-to-list 'TeX-output-view-style
		            '("^pdf$" "."
		              "/Applications/ %n %(OutFullPath)"))
		        (add-to-list 'TeX-expand-list
		            '("%(OutFullPath)" (lambda nil
		                                  (TeX-active-master (TeX-output-extension) t)

Please note: this section is based on the suggestions of Kasper Daniel Hansen.