From 8f259e469ca089529e1bfab8337d8b44e1524ae9 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Tue, 22 Jan 2013 18:02:05 +0100 Subject: [PATCH] Emacs: one-way SyncTeX support with Zathura. (From PDF to source file.) --- .emacs.d/modes.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.emacs.d/modes.el b/.emacs.d/modes.el index 7a3aac70..a4b2b09f 100644 --- a/.emacs.d/modes.el +++ b/.emacs.d/modes.el @@ -125,10 +125,22 @@ ;; I find the default tex-mode and AucTeX quiet disappointing. I'm using custom ;; functions for everything. -(defcustom tex-my-viewer "zathura --fork" +;; (defcustom tex-my-viewer "zathura --fork" +(defcustom tex-my-viewer "zathura --fork -s -x \"emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"'\"'\"%{input}\"'\"'\")) (goto-line %{line}))'\"" "PDF Viewer for TeX documents. You may want to fork the viewer - so that it detects when the same document is launched twice, - and persists when Emacs gets closed." +so that it detects when the same document is launched twice, and +persists when Emacs gets closed. + +Simple command: + + zathura --fork + +We can use + + emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))' + +to reverse-search a pdf using SyncTeX. Note that the quotes and double-quotes matter and must be escaped appropriately. +" :safe 'stringp) (defcustom tex-my-compiler "pdftex" @@ -136,7 +148,7 @@ Examples: pdftex, pdflatex, xetex, xelatex, luatex, lualatex..." :safe 'stringp) -(defcustom tex-my-compiler-options "-file-line-error-style -interaction nonstopmode" +(defcustom tex-my-compiler-options "-file-line-error-style -interaction nonstopmode -synctex=1" "The options to the tex compiler. Options are set between the compiler name and the file name. @@ -154,6 +166,8 @@ Interresting options: * -shell-escape: allow the use of \write18{} from within TeX documents. This is a potential security issue. +* -synctex=1: enable SyncTeX support. + You may use file local variable for convenience: % -*- tex-my-compiler-options: \"-shell-escape\" @@ -225,6 +239,7 @@ WARNING: the -shell-escape option is a potential security issue." ) ;; TODO: rewrite this function using lists and/or macros. +;; Add .synctex.gz and .synctex (defun tex-clean () "Remove all TeX temporary files. This command should be safe, but there is no warranty."