5

The vim-latex-live-preview Vim plugin and with :LLPStartPreview periodically refreshes the resultant PDF (by calling pdflatex on the tex file).

After a refresh the location displayed in the PDF is unchanged (as one would expect, perhaps?).

The PDF viewer I'm using is evince, though I'm happy to change. zathura looks interesting.

What I need: After making a change in the source through vim, at the next refresh the PDF viewer should jump to the latest change. Much like Tex Studio does.

The only way I can imagine this is possible is to tell the PDF viewer to jump to a specific line/page/section.

Q: Is there a Vim plugin which accomplishes this?

Q: Is there a PDF viewer which allows jumping to a specific location in a file after a reload?

3

1 Answer 1

1

Can't tell how vim-latex's preview work, but setup forward and backward search in vim can be done with little configuration using zathura, based on this gist :

https://gist.github.com/vext01/16df5bd48019d451e078

Your insight is right. First, you ought to compile your pdf with synctex enabled (I imagine vim-latex does this automatically). Then, zathura has the --synctex-forward option that allows you to specify a location on the pdf to jump to. This is the "forward" direction. On the other side, there is -x command which tells zathura to execute command when you CTRL+Click. Finally vim can be launched with --servername nameserver so you can call it from outside (zathura's -x option) and jump to a specific location -- "backward" direction.

The gist gives a good implementation of this. Bellow is my slightly modified version :

Basically,

  • I always startup vim than <leader>p to open the pdf in the right place.
  • The vim alias automatically sets up a server, allowing external programs to talk to vim.
  • The mapping calls Synctex() which calls vimura external script, passing the --synctex-forward option and data from vim's context (line('.')...)
  • vimura calls zathura with both -x setup with vim and --synctex-forward retrieved from argument.
  • In the end, <leader>p moves the pdf to the right location, Ctrl+click moves vim to the right location.

Hope it makes it not too confusing.

0

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.