25

The title pretty much sums it up. I use the package srcltx in my documents. I am running Ubuntu with Kile 2.1 and Okular 0.8.2 as a viewer. I am pretty sure that inverse search should work, but I haven't been able to set it up. How does one configure the viewer and editor to make this feature work?

  • I wish to add that (my version of) Okular (0.20.2) has to be in "browse" mode, not in "zoom" or "selection" mode, for inverse search to work. (For all like me who drove crazy because they wouldn't understand why the feature suddently didn't work anymore.) – benjamin Apr 18 '17 at 5:47
17

Check this Ubuntu forums thread: How can I do an inverse search between okular and kile?

Here is a summary of the required steps (not tested):

  • Setup inverse search from Okular:

    Settings -> Configure Okular .. -> Editor -> Editor dropdown: "custom text editor"

    command: kile %f --line %l

  • Set up Kile to tell LaTeX to add source info, i.e., set LaTeX build tools from Default to Modern:

    Settings -> Configure kile -> Build -> LaTeX -> "Modern" in the dropdown menu

  • Add a new forwardDVI configuration:

    Settings -> Configure kile -> Build -> forwardDVI

    then:

    1. "new..." button on the right
    2. choose a name
    3. put the full path to the perl script (see below) as the command (don't forget to escape, i.e., put a backslash in front of any spaces)
    4. put '%target' as Options (the single quotes are important)

#!/usr/bin/perl
# kile2okular. (c) Ian Wood, 2010
# based on:
# kile2xdvi. (c) Juerg Wullschleger, 2009

if($ARGV[0] =~ m/file:(.*)#src:(\S*) (\S*)/){
$dviFile = $1;
$line = $2;
$sourceFile = $3;
$sourcePos = '--unique "'.$line.' '.$sourceFile.'"';
if($dviFile =~ m|.*/([^/]*.dvi)|){
$dviFile = $1;
}else{
print 'usage1: kile2xdvi <dvifile> or kile2xdvi "file:<dvifile>#src:<line> <sourcefile>"'."\n";
exit;
}
}else{
if((!$ARGV[0]) || ($ARGV[0] == "--help") || ($ARGV[0] == "-h")){
print 'usage2: kile2xdvi <dvifile> or kile2xdvi "file:<dvifile>#src:<line> <sourcefile>"'."\n";
exit;
}
$dviFile = $ARGV[0];
$sourcePos = '';
}
if (!(-e $dviFile)){
print "$dviFile: No such file.\n";
exit -1;
}

`okular --unique "$dviFile#src:$line$sourceFile"\n`;
exit;
  • It'd be great if you can provide a summary of what they found to eventually work. (The answer on the second page of that thread.) This is since (a) a summary can be much more readable and (b) just in case link-rot sets in and that thread disappears. I know this is Ubuntu we are talking about, but .... just in case. – Willie Wong Jul 28 '10 at 16:28
  • I got it working with the above steps but without resorting to the script but using okular as the embedded viewer.. – Johnson-Leung Jul 30 '10 at 23:06
  • 2
    What about for PDFLaTeX? – Alessandro Cuttin Aug 30 '10 at 16:18
  • 3
    @Alessandro C. You do the same thing for PDFLaTeX, just in the build environments choose PDFLaTeX to have the modern type. I also completely ignored the part about the perl script and it still works perfectly. – Dom Feb 17 '11 at 17:19
  • @Dom, Alessandro: I tried it with Kile 2.0.85 and Texlive 2009 in an up-to-date Kubuntu with Okular 0.11.2 and PDF inverse search with pdflatex doesn't work. I also left out the perl script part. DVI inverse search however works with okular. Dom, what versions are you using? – Turion Apr 18 '11 at 18:21
7

I tried what was described here and it did not work. I found this link from the University of Illinois and their suggestions worked; I'm working in Fedora 17, in case it makes any difference. Here is what they suggest:

  1. Open some LaTeX file in Kile
  2. Open "Settings -> Configure Kile..."
  3. Click "Tools -> Build -> LaTeX"
  4. Select the "Modern" configuration
  5. Set the options to -interaction=nonstopmode -src %source
  6. Click "ForwardDVI" in the list
  7. Select the "Embedded Viewer" configuration
  8. Click OK
  9. Click "LaTeX" in the build toolbar menu
  10. Click "ForwardDVI" in the view toolbar menu
  11. Open "Settings -> Configure Viewer..."
  12. Click "Editor"
  13. Select Kile as the editor
  14. Click OK
  15. Scroll to some interesting location in the document and hold down Shift while left-clicking on that location. It should jump to that spot in the LaTeX source.
  16. Scroll to some other location in the LaTeX source and click "ForwardDVI". It should jump to that location in the DVI.
1

Okular to Kile navigation did not work for me on Ubuntu 14.04.1 in the above mentioned manner.

Then in Configure Kile --> Tools --> Build -->"Select a tool" I selected all possible tools and where-ever Modern was available I chose it.

Then it worked. Otherwise I have been struggling for two two days, it did not work. I must have wasted about a couple of hours for this at-least.

Hope this post saves time for many other people.

-1

I am using Ubuntu 14.04. In my case, I could not get inverse search to work using any of the above suggestions while using latex. But it worked with pdflatex by choosing Modern configuration as Puneet suggested.

  • Welcome to TeX.SE! I guess this is meant as a comment? – Stefan Kottwitz Feb 1 '15 at 12:02

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.