Using TeXstudio with SumatraPDF

Suma­traPDF is my favourite pdf reader and TeX­studio is my favourite LaTeX edi­tor. Here’s how to get them to work nicely together.

Go to Options/​Configure TeX­studio and click on “Com­mands”. Beside Pdf Viewer, untick “Inter­nal viewer” and add the fol­low­ing command:

"c:/Program Files/SumatraPDF/SumatraPDF.exe" -reuse-instance %.pdf

(If you have Suma­traPDF stored some­where other than the spec­i­fied paths, you will need to edit this accordingly.)

Then you need to tell Suma­traPDF how to jump to the cor­rect line in TeX­studio. From within Suma­traPDF, go to Settings/​Options and set the inverse search com­mand to

"C:\Program Files\TeXstudio\texstudio.exe" "%f" -line %l

Change the path to TeX­studio if necessary.

In order to go from the tex file to the cor­re­spond­ing loca­tion in the pdf, you can add a For­ward­Search com­mand within TeX­studio. Select “User” from the main menu, then “User com­mands” and “Edit User com­mands”. Then add a com­mand with the fol­low­ing definition:

dde://"C:/Program Files/SumatraPDF/SumatraPDF.exe":SUMATRA/control/

(That should all be on one line with no space before [ForwardSearch. Again, edit the path for Suma­traPDF as nec­es­sary. Give the com­mand a name such as “For­ward­Search” and click “OK”. Now you should be able to jump to the cor­re­spond­ing part of the pdf file using “Alt-​​Shift-​​F1” (or what­ever key-​​combination is asso­ci­ated with your new command).

Being lazy, I pre­fer a sim­ple func­tion key. To map F2 to your new com­mand, select “Options/​Configure TeX­studio” and choose “Short­cuts”. Find your new com­mand under the User menu, dou­ble click to the right of it and select “F2” from the drop-​​down box. Pre­vi­ously F2 was mapped to LaTeX, but I never use LaTeX directly, so los­ing this func­tion is no problem.

Now you can dou­ble click on any part of the pdf from within Suma­traPDF and it should take you to the cor­re­spond­ing place in your tex file in TeX­studio. And then F2 will take you back again.

Related Posts:

  • Desalegn 1Delu

    Thank you so much. it was helpful

  • Dellu

    Great guide. I also love the two appli­ca­tions. thanks

  • Aline Menezes

    Thank you very much indeed!

  • Ivanil­son de Aragão

    This infor­ma­tion was very use­ful! Thank you.

  • ziv ran

    This is great. Just one lit­tle thing: how do you make suma­tra auto­mat­i­cally in focus
    when you for­ward search. Thanks.

  • Alex

    Many thanks from the most beau­ti­ful coun­try in the world (Italy ;-))

  • Xiaodong Qi

    In the newest ver­sion of TeX­Studio (2.5.2), the set­ting for exter­nal pdf viewer doesn’t work any more… I appre­ci­ate it if you can check and update the settings.

  • Charles

    Thank you very much. I’ve been look­ing for these Tex­Studio and Suma­tra com­mands a lot, and then all of them are neatly described here. Cheers.

  • Pingback: LaTeX unter Windows mit TeXstudio und Sumatra PDF « geloest()

  • Bianca

    This would be very help­ful but it seems my Suma­traPDF viewer, in the “options” menu, has no way to input the inverse search com­mand, just has “view” and “advanced” tabs. Any help wpuld be appreciated

  • Big T

    Thank you very much. It was pretty dif­fi­cult to find these com­mands after the path by myself.

  • Guest

    Great guide, con­tain­ing exactly the infor­ma­tion I needed. Thank you!

  • Slamet

    it seems out­dated tuto­r­ial, Sir. and I haven’t found another sim­i­lar post like this from google yet

    • Rob J Hyndman

      Yes, this is out of date. But the inbuilt pdf viewer in tex­studio is now very good and so I’m using that rather than sumatrapdf.

      • Slamet

        but any­way, thanks for the tuto­r­ial. I got some hid­den fea­tures of Suma­traPDF instead

  • Oskar

    Thank you very much, this works really per­fect! I got all the things above work­ing. Just needed to add an extra /​ in the dde call i.e. dde:///

  • Bruce

    Thanks for sharing.

  • Majid Rafiee

    your very help­ful guide.
    how­ever, some issues may be noted:
    1. the first com­mand line must be replaced by: “c:Program FilesSumatraPDFSumatraPDF.exe” –reuse-​​instance %.pdf
    (the back-​​slashes must be used)
    2. dde:// at the third com­mand should have three slashes so that it must be replaced by: dde:///
    3. I couldn’t find the user menu under short­cuts in the tex­studio con­fig­u­ra­tion.
    finally, I’m so grat­ful for your invalu­able guide for how to sync tex­studio and sumatrapdf.