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


5 Answers 5


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


I just made a doc describing how to setup Texmaker and SumatraPDF with forward and inverse search, but fully portable which is bit tricky. Link to the how-to http://goo.gl/hxDeu (without redirect: http://goo.gl/hxDeu+) or see below:

1. Configuring Texmaker to use SumatraPDF as external PDF viewer with forward search Open your portable Texmaker and set path to external viewer as follows:

./SumatraPDF/SumatraPDF.exe %.pdf -reuse-instance -forward-search %.tex @

Note that path to SumatraPDF.exe is relative to Texmaker executable and you may need to edit this path to match your folder structure.

Texmaker -> Configure Texmaker -> Commands

2. Configuring inverse search in SumatraPDF

By default SumatraPDF does not allow to configure inverse search via GUI. Run once the following command:

SumatraPDF.exe -inverse-search "texmaker.exe %f -line %l"

You should not change the path to texmaker.exe file, even if you have different folder structure than I had.

SumatraPDF option window with unhidden inverse search settings

3. Create startup batch file

Due to some limitations in SumatraPDF we have to start Texmaker with following batch file everytime we want to use SumatraPDF as external viewer. Place the following commands in texmaker-portable.bat and save this file to the same folder as Texmaker.exe. Also note that you can pass any parameter to texmaker-portable.bat that you could pass to texmaker.exe itself.

@echo off
set PATH=%~dp0;%PATH%
start /D "%~dp0" texmaker.exe %*

4. Run texmaker-portable.bat and test the settings


  • make sure you are using -synctex=1 or -synctex=-1 parameter while formatting a tex file
  • the tex file should not contain space in its name (Texmaker and SumatraPDF handles spaces just fine, but SyncTeX file may not be created even with -synctex=1 parameter)
  • make sure you started Texmaker with the batch file and SumatraPDF via Texmaker (this chain is mandatory)
  • 1
    Thanks, that is interesting, I just gave you an upvote. Some people on SX do not like answers that are just links though, so maybe you could copy the content and post it directly here on SX?
    – matth
    Commented Mar 1, 2012 at 16:55
  • 2
    Thanks to your upvote I've earned the privilege to answer with wiki posts, so I guess I could copy the doc even with the screenshots. Commented Mar 2, 2012 at 17:21

This is meant to be a response to the answer from Vlastimil above. I found that inverse search works fine without the batch file. I just use the following line in Sumatra PDF Options (it came up automatically as an option). I'm using Sumatra 2.1.1 and Texmaker 3.5.

"C:\Program Files (x86)\Texmaker\texmaker.exe" "%f" -line %l

As others have stated, forward search works as well with the command line in Texmaker's options:

"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance %.pdf -forward-search "#.tex" @
  • 1
    Just want to say only this method worked for me. not any of other methods.
    – Sadegh
    Commented Dec 1, 2015 at 18:56

I'm not using TeXmaker but TeXstudio (formerly known as: TeXmakerX) instead. It is quite similar to the TeXmaker but has some nice additional features like code folding. For this editor I can give you a solution to the Forward Search problem. With TeXstudio you have two options: You can reconfigure the viewer command ("Options/Configure TeXstudio" -> "Commands"), thereby changing the standard PDF viewer to SumatraPDF, or if you want to use another standard viewer for some reason, you can go to the User menu (User/User Commands/Edit...) and define a new User Command. In both cases you have to enter the following into the respective command field:


where you have to replace C:/Programme/SumatraPDF/SumatraPDF.exe with your own path to SumatraPDF.

If required I could also provide configurations of Forward/Inverse-Search for other editors like TeXnicCenter and Emacs.

  • Rigth now I only get "Error : could not start the command". Maybe this is because Texmaker uses %.pdf instead of ?am.pdf. But what do I have to use instead of ?c:am.tex ?
    – matth
    Commented Dec 7, 2011 at 8:32
  • Even the simpler dde://C:/Programme/SumatraPDF/SumatraPDF.exe:SUMATRA/control/[Open("%.pdf", 1, 1, 0)] gives the same error. Not sure what I am doing wrong.
    – matth
    Commented Dec 7, 2011 at 8:39
  • 1
    @matth Could be just that you're using TeXmaker, and not TeXstudio. They are after all different programs, and the current version of TeXstudio is based on 2.x of TeXmaker, which itself is in version 3.x. Commented Dec 7, 2011 at 8:54
  • @TorbjørnT. that might be. But the DDE command even fails with hardcoded path, without variables like %.pdf. Do you think Texmaker does not allow DDE commands at all?
    – matth
    Commented Dec 7, 2011 at 9:06
  • @matth Apparently it didn't in 2008 at least, I don't know if anything has changed. There's nothing about it in the changelog though. Commented Dec 7, 2011 at 12:31

This answer aims to comprehend the steps for both TeXmaker v4.5 and TeXstudio v2.12.22 with SumatraPDF v3.2


  1. In Texmaker, go to Options > Configure Texmaker > Commands
  2. In External Viewer field (in case you are using SumatraPDF), type

    "C:\Program Files\SumatraPDF\SumatraPDF.exe" -1 -s @%.tex %.pdf

enter image description here

  1. In SumatraPDF, go to Settings > Options, then type in Set inverse search command-line

    "C:\Program Files (x86)\Texmaker\texmaker.exe" "%f" -line %l

enter image description here


In case you are using TeXstudio

  1. In TeXstudio, go to Options > Configure TeXstudio > Commands
  2. In External PDF Viewer field, type

    "C:\Program Files\SumatraPDF\SumatraPDF.exe" -reuse-instance -inverse-search "\"C:/Program Files (x86)/texstudio/texstudio.exe\" \"%%f\" -line %%l" -forward-search "?c:am.tex" @ "?am.pdf"

enter image description here

  1. In SumatraPDF, go to Settings > Options, then, in Set inverse search command-line, type

    "C:/Program Files (x86)/texstudio/texstudio.exe" "%f" -line %l

enter image description here

  • 1
    I tried about 38 options for getting forward search TexStudio -> Sumatra to work, and yours did the trick!
    – Eike P.
    Commented Jun 30, 2020 at 14:58
  • 1
    @jhin Glad it helped you 🙂
    – Diaa
    Commented Jun 30, 2020 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .