I’m trying to sync my .tex file with the .pdf output with a forward search on OS X using Emacs + AUCTeX and Skim.app. I have added the following code to my Emacs configuration:
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-PDF-mode t)
;; Use Skim as viewer, enable source <-> PDF sync
;; make latexmk available via C-c C-c
;; Note: SyncTeX is setup via ~/.latexmkrc (see below)
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
:help "Run latexmk on file")
TeX-command-list)))
(add-hook 'LaTeX-mode-hook (lambda ()
(push
'("pdflatex" "pdflatex -synctex=1 %s" TeX-run-TeX nil t
:help "Run pdflatex with SyncTex on file")
TeX-command-list)))
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "pdflatex")))
;; use Skim as default pdf viewer
;; Skim's displayline is used for forward search (from .tex to .pdf)
;; option -b highlights the current line; option -g opens Skim in the background
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))
(add-hook 'LaTeX-mode-hook
(lambda () (local-set-key (kbd "<M-S-mouse-1>") #'TeX-view)))
(setenv "PATH" (concat "/usr/texbin" ":" "/Applications/Emacs.app/Contents/MacOS" ":" "/usr/local/bin" ":" (getenv "PATH")))
(setq exec-path (append
'("/usr/texbin"
"/Applications/Emacs.app/Contents/MacOS/libexec"
"/Applications/Emacs.app/Contents/MacOS/bin"
"/usr/local/bin") exec-path))
Everything works fine in the main document, however, when I try to use forward search in an included file, say chapter1.tex
, I get an error:
Output file "chapter1.pdf" does not exist.
chapter1.tex
, did you? – giordano Nov 29 '14 at 8:44