Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

LyX /

SyncTeX

Categories: Category SyncTeX
<< | Page list | >>

--which version of LyX is described? 1.6 and 2.0 have completely different approach to it. note that lot of info about forward/reverse search in lyx advanced manual --ps

This page describes how to use SyncTeX to get reverse search, that is, the ability to get from a line in a PDF to the same line in the LyX document with a single click.

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 Also, seems like it doesn't work with child documents, see bug tracker http://www.lyx.org/trac/ticket/7186

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"
  • Modify Output > General > PDF for your PDF viewer (see the viewer-specific notes below)

Viewer-specific notes

Skim

In LyX,

  • Tools > Preferences > Output > General > PDF command: /Applications/Document_Viewers/Skim.app/Contents/SharedSupport/displayline $$n $$o $$t

In Skim:

  • Skim PDF-TeX Sync setting: Custom
  • command: /Applications/LyX.app/Contents/MacOS/lyxeditor
  • arguments: "%file" %line; /usr/bin/osascript -e 'tell application "LyX" to activate'

Okular

In LyX,

  • Tools > Preferences > Output > General > PDF command: okular --unique "file:$$o#src:$$n $$f"
  • This only works in LyX version 2.0.5+

In Okular:

  • click Settings > Set up Okular
  • Click Editor, and select LyX-client from the drop-down list.
  • If it doesn't work, try "Custom editor" and insert lyxeditor %f %l

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.

Sumatra PDF (on Windows)

reverese search only using server pipe:

In LyX

  • add \usepackage{pdfsync} to LaTeX preamble
  • add SumatraPDF.exe to LyX's search path: Tools > Preferences > Paths > PATH prefix
  • set Tools > Preferences > Paths > LyXServer pipe to "\\.\pipe\lyxpipe"
  • In Tools > Preferences > File Handling > File Formats select "PDF (pdflatex)" from the list of Formats and modify "Viewer" to: SumatraPDF -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)

In Windows:

  • create a batch-file in LyX's search path (e.g. ..\LyX\bin\) named "lyxeditor.cmd":
    @echo off
    SETLOCAL enabledelayedexpansion
    set file=%1
    set row=%2
    REM remove quotes from variables 
    set file=!file:"=!
    set row=!row:"=!
    %comspec% /q /c (@echo LYXCMD:revdvi:server-goto-file-row:%file% %row%)> \\.\pipe\lyxpipe.in&&type \\.\pipe\lyxpipe.out
    endlocal
    

Forward and Reverse Search Settings for LyX 1.6.*

To get this wonderful feature, you'll have to (1) enable SyncTeX in LyX, and (2) set LyX as the editor in your PDF reader.

Enable SyncTeX in LyX

First you'll have to ensure that LyX writes the SyncTeX file which tells your PDF reader about the correspondences between PDF positions and source document positions.

  1. Enter Tools > Preferences > File Handling > Export programs
  2. Click "LaTeX (pdflatex) > PDF (pdflatex)" in the list. In the "Export program" box, it now says pdflatex $$i. Instead, put pdflatex -synctex=-1 $$i there.
  3. Click Modify to the right of the list, then Apply.

(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

  1. In Okular, click Settings > Set up Okular
  2. 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

  1. In Skim, click Preferences > Sync
  2. 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

See http://wiki.lyx.org/LyX/LyXOnCygwin#toc6

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.)

Categories

Category SyncTeX

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2013-01-25 02:16 CET