Search:   Help



LyX documentation


Shared groups


LyX /


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

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, and forward search, that is, the ability to get from a line in the LyX document to the same line in the PDF viewer. Forward search is achieved by right-clicking in the LyX document and choosing "Forward Search".

1.  Forward and Reverse Search Settings for LyX 2.0 and Newer

1.1  Setting up LyX

  • In Document > Settings > Formats, 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 Preferences > Output > General > PDF command for your PDF viewer (see the viewer-specific notes below)

1.2  Caveats

  • MacOSX and renamed Forward/reverse search does not seem to work (on OS X at least) if the is renamed or not in /Applications. A work-around for this is to put a symlink (symbolic link) in /Applications that points to Using an OS X alias will not work. To create the symlink, open which is in /Applications/Utilities by double-clicking on it. Then paste a line like the following
ln -s /path/to/ /Applications
where /path/to/ is the path to the folder containing Hit return and quit Check /Applications to see if the symlink is there – it should look like the 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; see

1.3  Viewer-specific notes


As opposed to many other readers, forward and backward search with evince requires some helper scripts to be installed (since evince uses the D-Bus channel to communicate with editors). These scripts can be downloaded here. Installation and setup instructions are included in the ZIP archive (see README file).

If the scripts don't work out of the box, the reason might be your LyX generating "[filename].synctex" files instead of "[filename].synctex.gz" (the scripts assume the latter). In this case, you must replace the line synctex_file += ".synctex.gz" by synctex_file += ".synctex" in the script evince_sync_lyx .

Depending on your system's configuration, you might have to change the python interpreter in the first line of the scripts from #!/usr/bin/python to #!/usr/bin/python3 , if the former one points to Python version 2.x, and things do not work.


In LyX,

  • Tools→Preferences→Output→General→PDF command: /path/to/ $$n $$o $$t where /path/to/ is the path to which is frequently just /Applications/.

In Skim:

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


In LyX (Forward search):
  • Tools→Preferences→Output→General→PDF command: okular --unique "file:$$o#src:$$n $$f" or okular --unique "$$o#src:$$n $$f" (Windows)
  • On Windows: Add KDE's bin path (e.g. C:\ProgramData\KDE\bin\) as search path to LyX, separated with semicolon before (at Tools→Preferences→Paths→PATH)
  • This only works in LyX version 2.0.5+
In Okular (Inverse search):
  • Click Settings→Configure Okular
  • On Linux:
* Click Editor, and select LyX-client from the drop-down list.
* If it doesn't work, try "Custom editor" and insert lyxeditor %f %l
  • On Windows:
At the following two subpoints, change LyX's bin path (here as an example C:\Program Files (x86)\LyX\bin\)) accordingly:
* Click Editor, select "Custom Text Editor" and insert "C:\Program Files (x86)\LyX\bin\lyxeditor.cmd" "%f" "%l" (don't delete the quotation marks before "C:" and after "cmd")
* create a batch-file in LyX's bin path 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\ \\.\pipe\lyxpipe.out

  • 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.
NB: This only works in Browse mode - for example, pressing Shift-click will not do anything in Text Selection mode:


In LyX

  • Modify Preferences > Output > General > PDF command to be qpdfview --unique "$$o#src:$$t:$$n:0"
  • In Preferences > File Handling > File formats verify that the viewer in the various PDF (*) formats is set to qpdfview --unique

In qpdfview

  • In Edit > Settings > Source editor and insert lyxclient -g %1 %2
  • (optional) Modify Edit > Settings > Modifiers > Open in source editor to your liking (not all options work, try "Ctrl and Alt").
  • To use reverse search, in qpdfview:
* Right click the document and choose Edit 'file.tex' at... ;
* Hold the selected modifier key(s) while left-clicking the document.

Zathura (on Linux)

In LyX:

  • Tools→Preferences→Output→General→PDF command: zathura --synctex-forward $$n:1:$$t $$o (don't miss space before $$o).

In Zathura:

  • Open Zathura config file, usually in home directory ~/.config/zathura/zathurarc
  • add to it:

    set synctex true
    set synctex-editor-command "lyxclient -g %{input} %{line}"

Sumatra PDF (on Windows; Updated 2019-07-04)

Tools → Preferences → Path

  • Add the directories, C:\Program Files (x86)\SumatraPDF & C:\Program Files (x86)\LyX\bin, (where SumatraPDF.exe and LyX reside), to the PATH prefix line. NOTE this is important to get right the system command from LyX should be simply SumatraPDF.exe (then the -forward-search "TeX" line# and "preview.pdf" filename) equally the system call back from SumatraPDF to LyX pipe is via "lyxeditor.cmd" "%f" %l
  • Set the system memory line handle LyXServer pipe to \\.\pipe\lyxpipe.

Tools → Preferences → File Handling → Converters

  • Select the format LaTeX (pdflatex) -> PDF (pdflatex)
  • Set the entry converter to
     pdflatex -interaction=nonstopmode -synctex=1 $$i
  • Click Modify (otherwise the change will be discarded).
  • This change is needed to make MikTeX produce a FILE.synctex.gz synchronisation file.

Tools → Preferences → Output → General

  • In the “forward search” section set the entry PDF command to
     SumatraPDF -reuse-instance -forward-search "$$t" $$n "$$o"

Tools → Preferences → File Handling → File Formats

  • Select the format PDF (pdflatex)
  • Set the Viewer field to Custom with a command
    SumatraPDF -reuse-instance -inverse-search "CMD /C (ECHO LYXCMD:revdvi:server-goto-file-row:%f %l) > \\.\pipe\"
    (Note: inverse search of .lyx files with spaces or other special characters in the path or file name may not work with this approach on some Windows systems)
  • You may need to close all SumatraPDF windows and use “Document → View”.


  • You set inverse search command directly in SumatraPDF by going to “Preferences → Options” and set the fields “Command line for the inverse search” to "C:\Program Files (x86)\LyX\bin\lyxeditor.cmd" "%f" %l (don't delete the quotation marks before "C: and after cmd" or the ones either side of "%f" ) (the lyxeditor.cmd file must be created as per the instructions above for the Okular viewer, and is probably best place somewhere else than LyX's install folder...)
  • In this case you can reduce the “Viewer” command to SumatraPDF.


  • Unlike in some plain-LaTeX editors, forward search will not be toggled by the “Document → View” command; It must be explicitly used with “Right Click → Forward Search”.
  • Inverse search (from SumatraPDF to LyX) is effected by double clicking on a line in Sumatra.

Additional Remarks

  • The current version was tested with LyX 2.1.3 and 2.1.4. UpTo LyX 2.3.3 (2019) and SumatraPDF v.3.1.2 (32/64 bit) on Windows XP - Win 10.
  • If the path to the LyX file contains blanks, the synchronization may or may not work. In case the synchronization does not work and the path contains blanks, one can try changing the directories and/or file names so that they do not contain the blanks (tested on Windows 10 on 2019-06-25).
  • The older versions and current 3.1.2 just need exactly the same simplified SumatraPDF “editor” command as mentioned above in the section for Okular. "C:\Program Files (x86)\LyX\bin\lyxeditor.cmd" "%f" %l (don't delete the quotation marks before "C:" and after "cmd")
  • If pasting from the wiki into LyX (e.g. SumatraPDF) when following these instructions, ensure that you do not also paste a bullet at the start of the entry!
  • Judging from the old text, the “Converters” setting wasn't required before LyX 2.1.x.
  • The old version of this section mentioned an alternative value of \\.\pipe\C:\lyxserver in case that reverse search doesn't work.If you try, you need to change \\.\pipe\ into \\.\pipe\C:\
  • Renaming the pipe to C:\lyxserver shouldn't make any difference, as on Windows named pipes reside in their own namespace, separate from user-accessible files. \\.\pipe\C:\lyxserver should have nothing to do with the file \\.\C:\lyxserver aka C:\lyxserver

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

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

2.2  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

  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 as your previewer: In LyX, click Preferences > File formats > PDF (pdflatex), enter open -a $$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


3.  Troubleshooting SyncTeX

Make sure that the 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.

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

5.  Categories

Category SyncTeX

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2022-03-23 07:32 UTC