A blog by Rob J Hyndman 

Twitter Gplus RSS

Using TeXstudio with SumatraPDF

Published on 11 October 2011

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

Go to Options/​Configure TeXs­tu­dio 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 TeXs­tu­dio. 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 TeXs­tu­dio 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 TeXs­tu­dio. 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/
  [ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]

(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 TeXs­tu­dio” 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 TeXs­tu­dio. And then F2 will take you back again.


Related Posts:


 
Tags: ,
4 Comments  comments 
  • 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!

  • http://twitter.com/Fisicando Ivanil­son de Aragão

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