[Tex/LaTex] Configure forward search with Texmaker + SumatraPDF

forward-inverse-searchtexmaker

Texmaker has a Built-in pdf viewer which supports synctex forward/inverse search out of the box. This Built-in viewer can be displayed embedded or in a separate window, external viewers always have a separate window. As I have two screens, I am using the two-window layout.

Now I would like to switch to SumatraPDF as external viewer, but cannot find how to configure Texmaker to get Forward search working.
I have filed a feature request to add that information to the Texmaker documentation already. Does someone here know how to do it? Probably using some DDE command

Best Answer

It seems that Texmaker does not allow DDE commands, but since version 1.9 SumatraPDF supports forward search not only via DDE commands, but also via command line switches. Since version 3.2.1 Texmaker has all variables that are needed to use forward search. These are

  • % for the basename of the master file (without path and without extension),
  • ! for the full path to the directory where the master document resides,
  • # for the basename of the currently active file (without path and without extension) and
  • @ for the line number.

So usually the following should work:

""C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance "!/%.pdf" -forward-search "!/#.tex" @

This will fail when including from a subdirectory. A workaround is to add the subDirName to the path manually:

""C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance "!/%.pdf" -forward-search "!/subDirName/#.tex" @

But then the subDirName should be identical in all projects, so this is more a workaround than a real solution.

Here is a screenshot of my Texmaker configuration: enter image description here