TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Note, that since Texmaker, version 3.2.1, “an additional parameter (#) for the current file name is available for the commands (required for pdf synchronization with the sumatra pdf viewer)” (Changelog), cf. also this answer by Texenthusiast. – Speravir Apr 5 '13 at 20:49
issue 420 was deleted, still available on the web archive: web.archive.org/web/20130610162215/http://code.google.com/p/… – matth Jul 2 '15 at 15:07
up vote 11 down vote accepted

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

share|improve this answer

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)
share|improve this answer
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 Mar 1 '12 at 16:55
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. – Vlastimil Ovčáčík Mar 2 '12 at 17:21

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.

share|improve this answer
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 Dec 7 '11 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 Dec 7 '11 at 8:39
@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. – Torbjørn T. Dec 7 '11 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 Dec 7 '11 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. – Torbjørn T. Dec 7 '11 at 12:31

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" @
share|improve this answer
Just want to say only this method worked for me. not any of other methods. – Woeistg Dec 1 '15 at 18:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.