I edit .tex file under Emacs and view them with Okular.

I have already set up the backward search: from .pdf to .tex by pressing Shift+Left click on the .pdf file. The related part of .emacs file is here:

(add-hook 'LaTeX-mode-hook 'TeX-PDF-mode) 

(defun pdf-with-okular ()
 (add-to-list 'TeX-output-view-style
 (quote ("^pdf$" "." "okular %o %(outpage)"))))

(add-hook 'LaTeX-mode-hook 'pdf-with-okular t)
(setq TeX-view-program-list '(("Okular" "okular %o"))) 
(setq TeX-view-program-selection '((output-pdf "Okular") (output-dvi "Okular")))

 '(LaTeX-command "latex -synctex=1")
 '(cua-mode t nil (cua-base))
 '(show-paren-mode t))

However, I do not see how to make "forward" search work. Someone says when we position somewhere in the .tex file, press C-c C-v, we could go to the corresponding location of .pdf file. But here, when I press C-c C-v it opens another okular and we are always on the first page of the .pdf file.

P.S. My whole .emacs.

3 Answers 3


Try this instead:

okular --unique %o#src:%n%b

This is what I use and works fine. Should definitely not open another window with the --unique command so something else is up if that occurs. A similar solution is in link below but through the menus not in the .emacs file. Should just be able to use the command above with what you already have and should bring you to the line(%n) in the file when you run view or C-c C-v:



Unfortunately things became more complicated with TeX Live 2011. A temporary solution to make forward search work with Okular is described here:


Works for me, hope it will do for you, too.


Instead of

(quote ("^pdf$" "." "okular %o %(outpage)"))))

I have

(quote ("^pdf$" "." "okular --unique -p %(outpage) %o"))))
  • 1
    Thanks for your reply. But C-c C-v still opens another okular and it does not locate to the right position...
    – SoftTimur
    Jun 7, 2011 at 1:41

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.