Forward and Reverse Search Settings for LyX 2.0

NB: forward/reverse search does not seem to work (on OS X at least) if the LyX.app is renamed or not in /Applications. A work-around for this is to put a symlink (symbolic link) in /Applications that points to Lyx.app. Using an OS X alias will not work. To create the symlink, open Terminal.app which is in /Applications/Utilities by double-clicking on it. Then paste a line like the following

ln -s /path/to/LyX.app /Applications

where /path/to/ is the path to the folder containing LyX.app. Hit return and quit Terminal.app. Check /Applications to see if the symlink is there—it should look like the LyX.app icon but with a small arrow added. Note that symlinks are different from aliases in that with an alias, if the target (pointed-to) file is moved, the alias will still point to it but the symlink will not. Finally, there is a free utility that can be used if one prefers to not use Terminal.app; see https://www.macupdate.com/app/mac/10433/symboliclinker.

Setting up LyX

In Document > Settings > Output, check Synchronize with output

If your viewer needs another output format than \synctex=-1 (which is the default), select it or insert it in "Custom Macro"

Now, holding SHIFT while clicking with your left mouse button somewhere in the PDF should make LyX move to the corresponding position in the source document. Note that this only works in Browse mode - for example, pressing Shift-click will not do anything in Text Selection mode.

In Tools > Preferences > File Handling > File Formats select PDF (pdflatex) from the list of Formats and modify Viewer to: SumatraPDF -reuse-instance -inverse-search "lyxeditor.cmd \"%f\" \"%l\""(Note: copy command as is -- do not remove any quotes! If sumatrapdf is not in search path replace SumatraPDF with the full command. Be careful to use double backslash in the full path)

(Some tutorials will tell you to use -synctex=1 instead. This enables compression, in order to save some disk space. However, the PDF readers I've tried have not been able to use the compressed file.)

Set LyX as SyncTeX editor in your PDF reader

If you use Okular

In Okular, click Settings > Set up Okular

Click Editor, and select LyX-client from the drop-down list.

Now, holding SHIFT while clicking with your left mouse button somewhere in the PDF should make LyX move to the corresponding position in the source document.

If you use Skim.app

In Skim, click Preferences > Sync

Select LyX in the menu

Now, holding COMMAND-SHIFT while clicking with your left mouse button somewhere in the PDF should make LyX move to the corresponding position in the source document.

In case LyX does not open Skim.app as your previewer: In LyX, click Preferences > File formats > PDF (pdflatex), enter open -a Skim.app $$i in the viewer setting. Then you need to click the Modify button, and then Save.

If you use Sumatra, yap or xdvi on Cygwin

Troubleshooting SyncTeX

Make sure that the .lyxpipe.in and .lyxpipe.out files do not exist when LyX is not running. (They are normally deleted when LyX quits, but if LyX crashes, they remain and prevent LyX from communicating with PDFView.) Their location can be found in LyX > Preferences > Paths.

SyncTeX vs pdfsync

Another possible way of getting reverse-search is adding \usepackage{pdfsync} to the LaTeX preamble. However, this method is seen as deprecated now. (SyncTeX was created by the same person as pdfsync, and has the potential for more precise positioning; although LyX is at the moment not able to completely make use of the extra precision.)