6

I have the source in one emacs buffer and the compiled pdf in another DocView buffer with auto-revert-mode enabled. Using latexmk -pvc to compile gives me live previews. Now I want to setup forward and inverse search. All the instructions I can find about using emacs with synctex involves some external viewer. Is there any way to do this at all?

  • I am assuming this is not possible based upon zero information in Google, except for a couple of comments here and there stating that they too believe it is not possible. – lawlist May 5 '13 at 21:01
2

You can use pdf-tools. It adds support for forward and inverse search using synctex. Quoting the commentary in one of the synctex related functions:

Correlate a PDF position with the TeX file.
\\<pdf-sync-minor-mode-map>
This works via SyncTeX, which means the TeX sources need to have
been compiled with `--synctex=1'. In AUCTeX this can be done by
setting `TeX-source-correlate-method' to 'synctex \(before AUCTeX
is loaded\) and enabling `TeX-source-correlate-mode'.

Then \\[pdf-sync-mouse-goto-tex] in the PDF buffer will open the
corresponding TeX location.

If AUCTeX is your preferred tex-mode, this library arranges to
bind `pdf-sync-tex-display-pdf-key' \(the default is `C-c C-g'\)
to `pdf-sync-display-pdf' in `TeX-source-correlate-map'. This
function displays the PDF page corresponding to the current
position in the TeX buffer. This function only works together
with AUCTeX.

After setting up AUCTex, yous should be able to forward search with C-c C-g and reverse search by double clicking on the pdf in doc-view (with pdf-tools enabled; i.e. invoke pdf-tools-enable first).

0

It works for me with this configuration file for latexmk:

$pdflatex = "pdflatex -src-specials -synctex=1 --shell-escape -interaction=nonstopmode -halt-on-error -file-line-error %O %S";
$pdf_previewer = "start evince %O %S";
$pdf_update_method = 0;
$sleep_time = 1;
$recorder = 1;

and this in the .emacs

;;correlate
(server-start)
(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode)
(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)
(setq TeX-source-correlate-method 'synctex)
(setq TeX-source-correlate-start-server t)
  • does that open doc-view or evince? – jens_bo Apr 28 '15 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.