Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

(server-start)
(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")))

(custom-set-variables
 '(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
add comment

3 Answers

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:

http://mathieu.3maisons.org/wordpress/how-to-configure-emacs-and-auctex-to-work-with-a-pdf-viewer

share|improve this answer
add comment

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

https://bugs.kde.org/show_bug.cgi?id=274294#c20

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

share|improve this answer
add comment

Instead of

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

I have

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

Your Answer

 
discard

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.