Friday, August 20, 2010

What is forward/backward searching?

Forward searching (in this context) is the process of editing a latex file and by a keypress and some magic you are catapulted into your pdfviewer to the exact same point that your cursor was pointing to in your editor.
Backward searching is the reverse process, where you click on some place in the pdf viewer and you are then referred to the source of this text within your favourite latex viewer.

Requirements:
Vim/MacVim and latex-suite; some pdfviewer (skim here) with pdfsync support and one of the two latex/tex packages pdfsync/synctex.

To make it work in Skim you need to open the preferences, goto the sync tab and enter:
Preset: Custom

Command: mvim

Arguments: --remote-silent +":%line;foldo!" "%file"
Drop this code into a file in your path and make it executable
#!/bin/sh

/Applications/Skim.app/Contents/SharedSupport/displayline -r "$2" "$1" "$3"
 
Then put this into your vimrc file:
let g:Tex_ViewRule_pdf = 'pathtofile'

let g:Tex_ViewRule_ps = 'pathtofile'

let g:Tex_TreatMacViewerAsUNIX = 1
This was the only way i could get it to work under vim and macvim simultaneously. Then you just need one last line in every tex file you want it to work to set everything up:
\usepackage{pdfsync}
It's really that easy. Now in order to jump from vim to skim you need to type \ls and to get from skim to vim you would Shift+Command-Click
Try it; its grand. Enjoy!

4 comments:

  1. Dumb question: What do you mean "drop this code into a file in your path"?

    ReplyDelete
  2. OK, I think you mean in any path referred to in the 'pathtofile' ... hoping to get this to work for months. now "\ls" won't do anything

    ReplyDelete
  3. whoah, it was just that I used a comma for mapping. It now works! This is an epic moment for me.

    ReplyDelete