7

Inverse search of a compiled file with -syntex=1 option is trivial: you just choose Configure -> Editor -> Kate option from Okular -> Settings menu, then use Shift-Click on your favorite line of the pdf file.

What about the forward search? How am I supposed to make Okular show a screen with a particular line pointed to in the Kate editor? Or in an abstract source editor, for that matter. No amount of search shows any clue.

It just works in some LaTeX IDEs, of course, but what is under the hood?

  • There's no answer for 'an abstract source editor' or, even, an editor with an unspecified viewer. It depends on the viewer accepting relevant information and the format it needs that information to be provided in. Then it depends on the editor formulating the request to the viewer in that specific way. Obviously, some of this is just a matter of configuring the editor, but it needs to provide a suitable variable which it will set appropriately. For example, I have Kile configured to use okular --unique '%absolute_target'. Obviously, okular is Okular. The --unique [target] ... – cfr May 10 '17 at 21:55
  • ... depends on okular expecting the information in that format. (--unique stops it opening a new instance of an open PDF.) But the %absolute_target is something Kile will replace with the appropriate reference. So your editor has to expose this information to you in the form of a suitable variable. Kate may well do this or you may be able to make it do this, given that Kile is basically a wrapper for Kate. But Kile obviously makes this easy because its whole point as a wrapper is to provide the bells and whistles TeX users are apt to find useful. – cfr May 10 '17 at 21:58
  • “What is under the hood” — the current best “just works” technology is called SyncTeX. (This is what is used by AUCTeX in Emacs, for example.) See the TUGboat article Direct and reverse synchronization with SyncTEX by its creator Jérôme Laurens, especially section 4.3 “How SyncTeX works”. You can also see its official page and a question on this site about it. – ShreevatsaR May 10 '17 at 22:25
  • Yes, it's Kate. No, synctex is not a problem. Neither is executing a shell command okular --unique... from wherever you please by whatever shortcut/menu item you please. The huge problem is to get any information about that [target], or even a hint of its existence. Yes, in full it is okular --unique 'file.pdf#src:linenumber file.tex'. It took a huge amount of inventive googling. No manner of Okular docs, man okular or whatever, ever mention it. Where are KDE programmer guides? – Alexey Orlov May 11 '17 at 04:48
  • @AlexeyOrlov You don't know how to do it in Kile do you?! For some reason, it isn't working for me any longer. – cfr Aug 13 '17 at 21:38
  • @cfr Are you getting a "Shell meta characters that cannot be handled are present in the options given to the tool" error? – JAB Nov 15 '17 at 01:01
  • @JAB No. Why? Are you? – cfr Nov 15 '17 at 04:59
  • @cfr That's the error I'm getting trying to use ForwardPDF from Kile to Okular (Okular to Kile works just fine still). I haven't made a question yet because I haven't had time to play around to see if it's only for the specific multi-file document I'm working with currently. – JAB Nov 15 '17 at 05:03
  • @JAB It has forgotten by shortcut again, but ForwardPDF works fine for me from the menu. However, I may not be using the same version of Kile as you. – cfr Nov 16 '17 at 01:05
  • @cfr It turned out the issue was due to the path of the PDF, spaces and such aren't escaped properly in the path when launching Okular (even though it builds just fine with the given path). – JAB Nov 27 '17 at 23:16

1 Answers1

0

To forward search with Texstudio and Okular, use this:

okular --unique %.pdf#src:@?a./?c:r./?c:m.tex

Frank
  • 191