You are not logged in.
I would like to set up AUCTeX to call upon Zathura as the output viewer - and enable synctex. I see the description of how to do this with the built-in TeX package in Emacs on the Arch wiki ( https://wiki.archlinux.org/index.php/em … eX_support ), but I wondered if anyone has it set-up to work with AUCTeX?
Last edited by emacsomancer (2014-11-05 20:15:14)
Offline
Not the nicest solution, but it should work,
1. Create file zathura-sync.sh somewhere in you path with the following contents:
#!/bin/sh
pos="$1"
pdffile="$2"
zathura --synctex-forward "$pos" "$pdffile" || \
(
zathura -s -x "emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'" "$pdffile" &
sleep 1; zathura --synctex-forward "$pos" "$pdffile" )
exit2. Add to .emacs or customize the emacs variable TeX-view-program-list
(setq TeX-view-program-list
'(("zathura"
("zathura" (mode-io-correlate "-sync.sh")
" "
(mode-io-correlate "%n:1:%t ")
"%o"))))3. Restart emacs
4. Customize TeX-view-program-selection to use "zathura" for output-pdf
Last edited by fedxa (2014-10-31 02:11:21)
Offline
Thanks fedxa! I'll try that.
Offline
Not the nicest solution, but it should work,
1. Create file zathura-sync.sh somewhere in you path with the following contents:
#!/bin/sh pos="$1" pdffile="$2" zathura --synctex-forward "$pos" "$pdffile" || \ ( zathura -s -x "emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'" "$pdffile" & sleep 1; zathura --synctex-forward "$pos" "$pdffile" ) exit2. Add to .emacs or customize the emacs variable TeX-view-program-list
(setq TeX-view-program-list '(("zathura" ("zathura" (mode-io-correlate "-sync.sh") " " (mode-io-correlate "%n:1:%t ") "%o"))))3. Restart emacs
4. Customize TeX-view-program-selection to use "zathura" for output-pdf
I can't seem to get this to work. When I run it from emacs, nothing happens.
If I try running the script "by hand" from the terminal (after having compiled a LaTeX file, like file.tex, in AUCTeX),
e.g. if I run something like
zathura-sync.sh 976:1:/path/to/file.tex /path/to/file.pdf, I get errors:
error: Could not find open instance for '/path/to/file.pdf' or got no usable data from synctex.
error: Error parsing command line arguments: Unknown option -s
error: Could not find open instance for /path/to/file.pdf' or got no usable data from synctex.What am I doing wrong?
Last edited by emacsomancer (2014-11-01 23:46:05)
Offline
Ok, seems zathura's interface is quite in a development stage. My script stoped working for me after I updated zathura to a later version ![]()
Try the following:
#!/bin/sh
pos="$1"
pdffile="$2"
zathura --synctex-forward "$pos" "$pdffile" || \
(
zathura -x "emacsclient --eval '(progn (switch-to-buffer (file-name-nondirectory \"%{input}\")) (goto-line %{line}))'" "$pdffile" &
sleep 1; zathura --synctex-forward "$pos" "$pdffile" )Offline
Many thanks - it now works perfectly! (Zathura is really great too - nice, quick, etc. - much better than Okular for editing TeX files.)
Offline
Just a quick remark: if you use a different master file synctex will not properly like this. This can be easily fixed by replacing
(mode-io-correlate "%n:1:%t ")with
(mode-io-correlate "%n:1:%b ")Offline
And another tip: replacing
(switch-to-buffer (file-name-nondirectory \"%{input}\"))with
(find-file \"%{input}\")automatically opens the correct files if they are not already open instead of just creating a buffer with that name.
Offline
Thanks Javafant - I'll try those.
Offline
A simpler solution to the same problem can be inferred from this page...
Combining it with the solutions illustrated here: Add the following to $HOME/.config/zathura/zathurarc
# $HOME/.config/zathura/zathurarc
# Adding reverse search between emacs and zathura
set synctex true
set synctex-editor-command "emacsclient +%{line} %{input}"For a quick and dirty check, try:
$ zathura --synctex-forward 1440:0:foo.tex foo.pdfTested. It works with
GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22) of 2020-08-13Try opening a pdf in zathura, and ctrl+click. It should work. Assuming, of course, that an emacs instance is running in daemon mode.
The forward search is relatively easy, and is also clearly listed on emacswiki and emacs stackexchange:
;; Add this to .emacs.d/init.el:
(with-eval-after-load "tex"
;; enable synctex support for latex-mode
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
;; add a new view program
(add-to-list 'TeX-view-program-list
'(;; arbitrary name for this view program
"Zathura"
(;; zathura command (may need an absolute path)
"zathura"
;; %o expands to the name of the output file
" %o"
;; insert page number if TeX-source-correlate-mode
;; is enabled
(mode-io-correlate " --synctex-forward %n:0:%b"))))
;; use the view command named "Zathura" for pdf output
(setcdr (assq 'output-pdf TeX-view-program-selection) '("Zathura")))The only advantage to using '-x' switch on 'zathura' commandline, is that FWIW, the synctex works even without explicitly having spawned the viewer with emacs.
Last edited by bvraghav (2020-11-07 02:58:06)
Offline