TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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:


share|improve this answer

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.

share|improve this answer

Instead of

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

I have

(quote ("^pdf$" "." "okular --unique -p %(outpage) %o"))))
share|improve this answer
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 '11 at 1:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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