I referred to the section "Sumatra PDF (on Windows; Updated 2015-10-19)" in the following documentation: https://wiki.lyx.org/LyX/SyncTeX to set up the forward and inverse search; however, it seems like it's not working! Did anyone succeed in successfully implementing these search options in LyX 2.3? If so, can you please guide me?



From MyNotes [Updated for latest 2.3.3 version 2019]

MiKTeX users are advised to update to the latest version before installing LyX 2.3.3+ for Windows.

If you have a permanent installation of SumatraPDF you only need to set -inverse-search ONCE, equally by using tabs we do not need to waste time deciding which session to address. Note it is possible to have multiple windows and sessions in SumatraPDF, but that is going beyond this answer.

The InverseSearchCmdLine = is permanently stored in SumatraPDF-settings.txt. It does not have to be configured by an editor unless you have to re-install or otherwise replace SumatraPDF-settings.txt (make a backup!)

Settings in SumatraPDF

Notable difference is we revert to the better stable Okular cmd file (Okular uses exactly the same calling system as SumatraPDF) this avoids any unnecessary calls.

SumatraPDF should be installed so it will function from any system call as SumatraPDF , this means it must be "on path" (if using a portable version SumatraPDF.exe must be temporarily added to the user path prior to first calling Lyx)

Run SumatraPDF and go to Settings > Advanced Options this will open SumatraPDF-settings.txt in NotePad, now going down the entries check or change the following.

ReuseInstance = true
ReloadModifiedDocuments = true
InverseSearchCmdLine = lyxeditor.cmd "%f" %l
EnableTeXEnhancements = true
UseTabs = true

Remember that %l is a lower case L and Do not forget to CTRL+S (File Save). If you are having to add the c:...LyX\bin\ to that InverseSearchCmdLine , then you have not installed LyX correctly. the .cmd file is in a bin folder that MUST be on the system path

Settings in LyX

Following the SyncTeX guide in https://wiki.lyx.org/LyX/SyncTeX

"(Note: inverse search of .lyx files with spaces or other special characters in the file name do not always work with this approach on some Windows systems)"

MY NOTES due to this unique method of calling a pipe [1] used by LyX in Windows, there is sometimes a requirement that the working file and its path MUST NOT HAVE A SPACE. So if that does not work for you then you will need to raise any issues with LyX support. If they provide a simpler way of calling an active LyXserver session with a remote quoted filename path, then please comment below. The issue is that LyXserver expects two sequential values 1) the SyncTeX supplied .tex filename 2) followed by the line number, so when a filename contains spaces the first part may not be valid as a filename and the second part is clearly not a number, It may work if filenames are parsed as older 8.3 format but most modern Windows files use LFN format. the lyxeditor.cmd file attempts to get around those issues.

Notable differences compared to any other approach are

Do not add the unnecessary and depreciated -reuse-instance or -inverse-search options / directives (they are not needed and slow down the correct -forward-search request.)

Tools → Preferences → Path
•Add the directory, where SumatraPDF.exe resides, to the PATH prefix line. (This should not be needed for a permanent install but may help for portable use)
•Set the line LyXServer pipe to \\.\pipe\lyxpipe (Do NOT use the browse button)

Tools → Preferences → File Handling → Converters
•Select the format LaTeX (pdflatex) -> PDF (pdflatex)
•Set the entry converter to
pdflatex -interaction=nonstopmode -synctex=1 $$i

Lyx Settings

•Click Modify (otherwise the change will be discarded).
•This change is needed to make MikTeX or TeX Live produce a FILE.synctex.gz file.

Exit and go back to check it IS modified, it took me a couple of go's resetting changes to get it set and sticky from one session to the next.

Tools → Preferences → Output → General
•In the “forward search” section set the entry PDF command to
SumatraPDF -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

•You may need to close all SumatraPDF windows and use “Document → View”.
•You can set inverse search command directly in SumatraPDF by going to “Settings → Advanced Options” as above and set the inverse search. In this case you reduce the “Viewer” command to simply


enter image description here

enter image description here

ANY problems with this Inverse Search call working are to be raised with Lyx support as it is their recommended method not mine!

[1] In principle using named pipes in memory speeds up and reduces the need to recall an application via the command shell parameters, however like DDE or D-bus methods its unfamiliar to most users and can be troublesome to debug issues easily.

Note Ensure lyx has a file open, ensure Enable Forward/Reverse button is active then compile and view finally right click and select about 6 options downForward search`

The locations are not 1on1 (the pages may often seem "off").
It can help to see the forward search by setting in SumatraPDF-settings.txt

HighlightPermanent = true

To return to the corresponding page simply double click any location in SumatraPDF so it calls the lyxeditor.cmd.

  • Thanks for the detailed instruction! I was able to get the inverse-search working in LyX. – Ashirwad Feb 26 at 20:58

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.