[Tex/LaTex] Set up SyncTeX with Emacs DocView

emacsforward-inverse-search

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?

Best Answer

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).