Friday, March 23, 2012

KILE: Workaround for forward search in Windows

The KILE builtin functionality currently adds as space and "./" to the source file when clicking ForwardDVI under windows with the current KDE Windows release. I do not have this behavior in Linux Ubuntu 10.04 with latest patches installed.
Still, this annoys  me and I came up with a workaround for Windows:

You need:

  • Cygwin with sed installed
  • Okular (any other dvi viewer should do fine)


Generate a build command in Kile-> Settings -> Configure Kile --> Build which is exactly the same as ForwardDVI.
Than change this new command to the following:

Command: cmd
Options: /c open_okular.bat '%target'

This should call the batch file open_okular.bat within the DOS CMD shell and pass along the string containing everything you need for doing forward search.

Now place the following DOS CMD script in your TEX Project Root folder:
FILE open_okular.bat


echo "Start"
set PATH=%PATH%;c:\programdata\kde\bin\;c:\cygwin\bin\;c:\Users\<username>\kderoot\bin\
echo  %INPUT%
for /f %%a in ('echo %1 ^| sed.exe -e"s/ \.\///"') do set OUTPUT=%%a
@echo %OUTPUT%
okular.exe %OUTPUT% --unique
echo "End"

What the script does:
Line 2 updates your path so that okular.exe and sed.exe are known. Adjust paths appropriatley
Line 4 removes the " ./" in words: space dot slash; from the string and stores it in OUTPUT
Line 6 calls okular with the new string.


This should give you the forward search for Kile and Okular in Windows.
Adoptions to any other DVI viewer should be straight forward.
Adoptions to Linux should be easy as string manipulation is usually a lot easier.






1 comment:

  1. Another workaround I came up is to give the full path to the latex compiler so it works with synctex. For that configured Kile the following way (partially based on your other post):

    Settings->Configure Kile…->Build->PDFLatex
    From dropdown menu choose: Modern
    General: Command: pdflatex
    Options: -synctex=1 -interaction=nonstopmode %dir_base/%source
    Advanced: Type: Run Outside of Kile
    State: Editor

    Options: %dir_base/%source compile the file using full path (%dir_base = path of the source file without filename, and %source = file name with extension), -synctex=1: synctex on, -interaction=nonstopmode: standard

    Settings->Configure Kile…->Build->ForwardPDF
    General: Command: okular
    Options: --unique: so no multiple instances of ocular, %absolute_taget
    Advanced: Type: Run Outside of Kile
    State: Viewer

    ReplyDelete