I know people have had this kind of problem before, but I haven't been able to find the solution to my problem anywhere.

First of all, calling Tex_ForwardSearchLatex() with <leader>ls doesn't work. A command window pops up and disappears (which, I suppose, is the viewer being called from the shell), but nothing happens. If the viewer is not already open, then this doesn't open it.

So I tried a custom function from this thread, with the same result.

function! SyncTexForward()
     let execstr = "silent !okular --unique %:p:r.pdf\\#src:".line(".")."%:p &"
     exec execstr
nmap <Leader>f :call SyncTexForward()<CR>

This solution is not supposed to work with \input{} and \include{} subdocuments, but I'm not even there yet. I'm just trying to get the main document to work.

Then I tried a modified version of the custom function that supposedly works with subdocuments as well, but again to no avail.

function! SyncTexForward()
     let execstr = "silent !okular --unique %:p:r.pdf\#src:".line(".")."%:p &"
     exec execstr
nmap <Leader>f :call SyncTexForward()<CR>

I thought it might be a problem with spaces in my file/directory names, but no. I've tried a file called test.tex at root with the same result. SyncTex is enabled and the viewers are on the path. The problem is likely what comes after \# (i.e. the crucial part), since :silent !okular --unique %:p:r.pdf works as expected.

I'm using Windows 7 and Okular, although I also tried SumatraPDF before, with exactly the same result. Frankly, I don't think the problem is with the viewer. Here's what I have in my tex.vim

let g:Tex_DefaultTargetFormat='pdf' 
let g:Tex_CompileRule_dvi='latex -synctex=1 --interaction=nonstopmode --src-specials $*'
let g:Tex_CompileRule_pdf='pdflatex -synctex=1 -interaction=nonstopmode $*'
let g:Tex_ViewRule_pdf='okular'

Note: The following is for Sumatra, not Okular as OP asked. However, I'm sure the problem for Okular is the same as Sumatra.

I think the problem is most likely with your version of Vim-Latex. I fixed the forward-search problem with Sumatra with this patch, as well as support for it here.

This patch doesn't seem to be in the newest version of Vim-Latex, nor was the diff file the patch provides (meaning the patch utility did nothing). I had to manually apply the patch to my ftplugin/latex-suite/compile.vim file, but after it worked fine.

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.