I am running spacemacs and pdf-tools on Ubuntu 18.04. It does work quite well, however now I asked myself whenever there is an option to do inverse search (or to make a new command doing inverse search) with a keyboard key.

The built in command Ctrl-Mouse-1 works well, but could I for example inverse search from the pdf back to the beginning of the page in the tex file with a keystroke? Or in a more sophisticated, but versatile way could I run pdf-occur, let the results show up and then go to the line in my editing file with a keyboard command?


If Ctrl-Mouse-1 works well for you, you can always write a function that emulates it's behavior and bind a key to it. If, as you indicate, you want to sync backward to the position in the tex-file corresponding to the beginning of the pdf page, you can emulate a Ctrl-Mouse-1 click on position (1,1) with the function:

(defun pdf-sync-backward-to-top-of-page ()
  "Use coordinate (1,1) to sync backward"
  (pdf-sync-backward-search 1 1))

and bind it to a key (here "s-t"):

(add-hook 'pdf-sync-minor-mode-hook
   (lambda () (define-key pdf-sync-minor-mode-map 
                 (kbd "s-t") 
  • Thank you for a tip. Right now, it doesn't work, I get Symbol’s function definition is void: \, error if I type in the command via M-x. The key sequence s-t is undefined for some reason. – Rareform Oct 21 '19 at 16:23
  • You have to execute the code above before you can use the function. If you put the code above into your .emacs configuration file, next time you start up Emacs you can press "s-t" (the meta and t key) in your pdf document and it will jump to the tex file as described. Of course, you can use any key combination you like instead of "s-t". – StarBug Oct 22 '19 at 6:43
  • You can also use isearch to search for some word, and subsequently use pdf-isearch-sync-backward to jump to that match in the source (of course you could make a keybinding also for that function) – dalanicolai Aug 30 '20 at 22:52

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.