# Synchronizing WinEdt and pdf files

Being able to go from a line in WinEdt to the corresponding place in a compiled document is extremely useful and saves a lot of time. This has long been possible using Yap with dvi documents, but Yap is slow and ugly and the dvi files usually have to be converted to pdf before sending them to anyone else.

So I tend to use pdftexify to create pdf files directly, but I miss having synchronization between what I write and the pdf file that is created.

However, I’ve found a solution that is not too difficult to implement and seems to work well. It replaces the Adobe pdf reader with SumatraPDF.  There is some fiddling of settings in WinEdt as explained in the instructions below. The information below is adapted from William Blum’s website.

1. Download SumatraPDF and install it to the (default) directory c:\Program files\SumatraPDF
2. For Winedt 6.0
Run WinEdt and go to Options/Execution Modes. Click on the “PDF Viewer” tab and click the “Sumatra PDF” button. Make sure the box under “Sync Tex” is ticked. Then click “OK”. That’s it!
3. For Winedt 5.6.
1. Download Acrobat OpenDoc.edt and Sumatra-Find.edt and save them to C:\Program Files\WinEdt Team\WinEdt\Exec
2. Run WinEdt and go to Options/Execution Modes. Click on the “Acrobat” tab and replace the path to the “PDF Viewer Executable” with"C:\Program files\SumatraPDF\SumatraPDF.exe" -reuse-instance. Like this:
3. Before closing the dialog box, go to the “Console Applications” tab and select “PDFTexify”. Change the switches field to--pdf --tex-option=--synctex=-1Similarly, for PDFLaTeX and PDFTeX, change the switches fields to--synctex=-1Then click “OK”.
4. In WinEdt, go to the menu ‘Option/Menu setup’. Create a new macro menu somewhere (under ‘Accessories’ for instance) and fill the options as follows:
Name: Sumatra Find

Macro: Exe('%b\Exec\Sumatra-Find.edt');

Requires File Filter: %P\%N.pdf

Start in: %P

Shortcut: Shift-F8

Now when editing a .tex file in WinEdt, you can go to the corresponding line in the pdf document by pressing Shift-F8.

#### Update

• The above instructions only work with MikTeX (tested on MikTeX 2.7 and 2.8). If you use TeXLive, or some other LaTeX implementation, then you will need to figure it out for yourself.
• You should not use the pdfsync package.
• Some people have reported trouble with beamer. I have had no difficulties using beamer with the above settings.
• The above instructions have now been updated (8 Sep 2009) to take account of all comments below.

### Related Posts:

• George

It has worked perfectly well. Thank you.

• the forward search does not work.

my winedt directory is

c:\winedt56

i have modified the line

“C:\Program Files\WinEdt Team\WinEdt\winedt.exe” “[Open(|%f|);SelPar(%l,8)]”

accordingly to

“C:\WinEdt56\winedt.exe” “[Open(|%f|);SelPar(%l,8)]”

and put the macro Sumatra-Find.edt into the directory

“C:\WinEdt56\exec

i get the error message unknown macro: Forward Search.

the inverse search works perfectly.

best regards
g. szeidl

• y. calleecharan

Thanks. Pressing F8 opens up the document to the page at which the document was browsed to after compilation. What am I doing wrong?

F8 is not opening at the corresponding line.

Best Regards
Y.Calleecharan

• y.calleecharan

Hello again,
Sorry about my earlier post. It works fine. I lost sight of the forest because of all the trees. I forgot to put \usepackage{pdfsync} in the preamble. Both forward and inverse search features seem to work fine.

Best Regards,
Y.Calleecharan

• To Y. Calleecharan: I think the problem is that you are using TeXLive rather than MikTeX. I have only tested the instructions with MikTeX 2.7. TeXLive does not have a texify command.

• y.calleecharan

Thanks. Yes indeed I’m using TeXLive. Alex from WinEdt also explained about the texify issue. I’m now just using –synctex=-1 (without putting the pdf before) everywhere for PDFTeX, PDFLaTeX, TeXify and PDFTeXify. Now I get a .synctex file at last. And I don’t need the pdfsync package. The forward search seems to go to a position with 2-3 lines earlier to where it is supposed to point. But I can live with that. So it’s working fine now with TeXLive 2008.

I have one question. Maybe you would be kind to help here:
Starting after a clean build, every time I press F8 the Sumatra window pops up maximized at the corresponding line entry (without I need to close the PDF viewer each time). I found that if I made an inverse search, then tries forward search again then the sumatra window is not maximzed as before. But of course still, sumatra is going to the right line in the PDF file. Closing the PDF window after an inverse search resets things to normal.

Is there a way by modifying the macro parameters to every time force the sumatra window to get maximized on screen when pressing F8? Or something like closing Sumatra first and then opening it again.

One more issue: I was surprised to see that when I click on a reference entry in the bibliography at the end of the PDF document, it opens up the .bbl bibliography file at the corresponding entry. Well, is it possible to open the .bib file instead of the .bbl file? This would indeed be very convenient if changes have to be made in the .bib file.

Thanks a lot

• Rob J Hyndman

1. For TeXLive there is no pdftexify so it doesn’t matter what switches you include. For pdftex and pdflatex you need --synctex=-1.

2. I think you probably mean that the sumatra window is not in focus (i.e., on top). By default, it remains hidden behind your WinEdt window. To change this, you need to modify the file Sumatra-Find.edt. Go to line 38 and change to the following:

DDEExe('[ForwardSearch("%P%N.pdf","%q%n%t",%!l,0,0,1)]');>

The only change here is the last digit is changed from 0 to 1.

3. I don’t think it is possible to create links to the bib file(s). The way BibTeX works is that the bbl file is first created, and this is used when constructing the pdf file. So any links back to the bib files are not available.

• y. calleecharan

1. Yes, you’re right. TeXLive is different.

2. Thanks a lot. With the change that you specified, it now works perfectly i.e. the Sumatra window can be brought at any time on the top.

3. No worries for this one. I’m just becoming lazy and want everything to do in the minimal time :).

Again, many sincere thanks for your kind help in taking time to help others. The forward- and inverse-search is indeed a big time saver. I never could make it work with Adobe Acrobat.

• y. calleecharan

Just a comment: In the instructions listed, I found that on my machine doing step 3 or a combination of steps 3 & 4 without doing step 2 will automatically brings the required changes in Sumatra regarding the path of WinEdt in Sumatra as being done in Step 2.

• Christian

Thank you for these detailed instructions. It works with my installation of WinEdt 5.5 / MikTeX 2.7 and the latest official release of SumatraPDF (0.9.4) from its official website. Seems that the special version specified in step 1 is no longer required.

There is, however, one more thing to consider with WinEdt. When the option “Start viewer” is active in one of the execution modes (step 4), for example in PDFTeXify, then the Adobe Reader will be launched on top of SumatraPDF. To avoid this behaviour, one should consider replacing the macro “Acrobat OpenDoc.edt” by an updated version:

“http://www.winedt.org/temp/Acrobat OpenDoc.edt”

Best regards –
Christian

• Thanks Christian. The instructions have been amended accordingly.

• Jan

Thanks Rob and Christian. The synchronization is working nicely.

As mentioned by Christian, with the latest version of SumatraPDF (beta 0.9.4) step 2 is not necessary anymore.

Best regards,
Jan

• Thanks Jan. I’ve deleted the old step 2 (and subsequent steps are now renumbered).

Hi

great that Rob updates infos here. I knew about Blum’ site but lot of old infos are confusing there.
My question is, cause I do not understand the varibales in the macro, whether I can install summatra somwhere else?
I need it in \B: in my WinEdt program directory.

thanks alot!

• You can install SumatraPDF wherever you like, so long as the directory is correctly specified in Step 3. The Sumatra-Find.edt macro will find SumatraPDF using the location specified in Step 3.

Thank you very much Rob.

I got it now running partly. Forward search by hitting F8 in WinEdt works more or less. It aims a bit besides.
But inverse or backward search is more importan for me and is not working. It seems to work on the first page but on page 2, 3, 4 etc. it isnt no more.

I write a paper with a known structure of projects that is like this.

+ main dir
-project file.tex
+ subdir
-chapter1
-chapter2

I use the include cmd, since I read that input is no good.
%\input{content/1-firstchapter.tex}

Bingo, I realized that you have NOT to use the “search forward” option under console applications! I think it is good to mention in your FAQ that users should backup their settings and then before they start editing the above content they press the button to set DEFAULT settings 🙂

Hello Rob

I got it now working and am very happy.

I want to ask you whether you want to publish an article on W. Blum’s
LatexDaemon.
There is so less information on it on the web despite it is such a great tool, when you can get it to run.

best regards

• Good to know it’s working for you. Thanks for the pointer to LaTeXDaemon — I’ll add it to my list of things to cover.

• Pedro

Hello Rob

Thanks! Works great, except in one situation.
If I call “Sumatra Find” when the pdf file is not already open in Sumatra, WinEdt hangs (busy for ever). I looked at the edt file but I am not sure how to test for this situation and open the file in Sumatra automatically.

I am using WinEdt 5.6 Beta and MikTeX 2.8 on Vista SP 2.

Very nice and useful blog, by the way. I am an agronomist turned biologist and use both LaTeX and R regularly, and find your blog and insights very useful.

• Ziv Ran

Thanks! It works perfectly (with MikTex 2.7). SO good to get
away from Yap.

The only slight improvement I can suggest is to make Windows focus on the Sumatra window

• pedalracer

Hello

It stopped working for me. Even forward search is no longer doing its job. All looks as it looks in this guide.

I wonder if there is something else important. I must ask what option is given under options/execution mode/tex options and there under
Tex auxiliary output folder?

Since I have my project structured in subfolders I assume that there is the culprit.

What I have is that I got the project.synctex with the project.pdf but Sumatra can’t use it for forward or inverse search. So I think that it may be linked to the fact that I have my chapters in the subdir \chapters\ ?!?

• I haven’t tested it using subfolders. On my system, I’m using %P as the auxiliary output folder.

• pedalman

Dear Rob

thank you for the information on the aux output folder. I reinstalled my Winedt on another machine in order to check what the default setting is there. However, I changed it to %P by checking the button in the options.
Unluckily, it is not working. I deleted all working files (aux etc.) and so on but I Sumatra is saying that
There is no syncronisation info at this point….. !?!

What a pity, since there is after each PdfLatex run a thesis.synctex. So, for some reasons Sumatra is not taking this into account. However, I implemented the Sumatra.edt macro and it once worked.
Maybe, there is a link to MikTex 2.8x?

• I don’t think I can help further. I now have it working on three computers, all with MikTeX 2.8 and SumatraPDF v0.9.4beta. It was previously working fine with MikTex 2.7 and SumatraPDF v0.9.3. The subfolders could still be your problem.

• pedalman

Ok,

thanks in advance for your patience. The good news are I found the problem and solved it!!

I think this will be helpful for others too.

I had to change all calls for any .tex fils from my project main file into XYZ.tex from originally XYZ without tex.

So in my case it has to look like.

\input{preambel/settings.tex}
\input{preambel/preambel.tex}
\input{macros/newcommands.tex}
\input{macros/TableCommands.tex}
\input{preambel/Hyphenation.tex}

Note the file endings when using input 🙂

cheers

• \input is not usually recommended. The preferred method is \include{}. You might find it works better with \include{}.

• Pingback: Converting eps to pdf | Research tips()

• Hi Rob

After some work I got it to work. I had to

1) change to DDEExe(‘[ForwardSearch(“%P\%N.pdf”,”%p%n%t”,%!l,0,0,0)]’);> line in Sumatra-Find.edt to DDEExe(‘[ForwardSearch(“%P\%N.pdf”,”%n%t”,%!l,0,0,0)]’);>

2) Moreover, inverse search did not work before installing William Blum’s own version of Sumatra pdf. Here you can set the commandline of inverse search. My problem was that it looked in the ‘Program Files’ folder. Mine is named ‘Programmer’ instead (Danish WinXP version).

cheers

• Marc

Thanks a lot for the detailed instructions!

Forward search works fine hitting F8, but not when clicking the PDFTexify button. Do you know of a way to also enable forward search with PDFTexify?

Inverse search works too, but only for the first two lines of a section. I guess this behavior is caused by me using soft word wrapping in WinEdt. For inverse search to work as expected one should probably resort to smart wrapping.

• Cris

I followed ypur pocedure and everything works well. The only problem that I have is with the shortkey F8. When I use it the Sumatra-Find.edt file is open and the following phase is highlighted

Run(‘%$(“AcroRead”); -reuse-instance -inverse-search “\”%B\WinEdt.exe\” What is the trouble? Thanks Cristina • Myriam Hello! I’m having troubles with the forward search. I did all the steps but when i am hitting the F8 key, I get an warning message saying: Keyword expected ^^^ ÿþ/ and then nothing happen… Any idea what could it be? Also 2 files open with sumatra when pushing the Textify button… Is that normal? Thanks for the help. • Both problems sound odd. I haven’t seen them before. Make sure you’re using WinEdt 5.6 and MikTeX 2.8. Otherwise I don’t know what the problems could be. • Peter Hi, Thank you very much for sharing this information. It works perfectly fine for me. I though have a question : why SumatraPDF ? Does it work with Acrobat Reader ? Best regards • No, it doesn’t work with Acrobat Reader. SumatraPDF allows the pdf file to be changed externally while it is still loaded. • Phillip Li Hi Rob, Thanks for the informative blog. I followed the instructions exactly and got it to work almost perfectly. When I press F8, the entire paragraph gets highlighted in SumtraPDF instead of the line. Is this normal? I’m using Winedt Build: 20071003 (v. 5.5) and SumtraPDF V1.0.1. Any ideas? Thanks a lot • Yes, that is normal. The sync markers are only done at paragraph level, not at line level. • Shane This is an excellent tutorial! Thanks for putting it up, its really helped me out! • Hans I am using Winedt 6 + Miktex 2.8. I have the problem that the Sumatra pdf does not update after a new PDF has been created and Sumatra has been invoked with forward search. Even with Shift+F8 (which will invoke the forward search), the forward search displays the correct location, but the document stays the same. The only possiblity to get Sumatra to show the new document is to close it or press “r” for reload. Is there a possiblity to have Winedt make Sumatra automatically reload the document before invoking forward search? • Hans I have found the error: The file was on a network drive! Sumatra does not refresh in this case. Solution is to copy it to the internal harddisk. • Yuval Will this sumatraPDF solution admit forward search also from file1.tex file2.tex etc that are attached to the main file with \include{file1} \include{file2}. I can not do such forward search with the YAP dvi (Is there a way to do it ?) So I may have two reasons to try your solution I use WinEDT 5.6 Miktex 2.7-2.8 Windows XP and Vista • Yes, I’ve just tried with WinEdt 5.6 using a file with several \include{}s and it worked fine. • Yuval Sounds good. Can I assume the dvi and SumatraPDF forward/backward searches will live happily side by side? (For small projects I expect to still prefer what seems to be a more accurate pointing of the yap) Thank you for your prompt response • Yes, they both work. Double click to get from either yap or SumatraPDF back to the relevant line in WinEdt. To go the other way, use Shift-F8 for pdf and Ctrl-Shift-S for dvi. • Yuval I went through the installation. Reversed search works fine. Direct search does not. More precisely, direct search works well from the main file but not from any of the include files. In other words, both YAP and the Sumatra can not do a direct search from any of the include files. On a second thought it kind of “makes sense” . The dvi search buttons are not highlighted in the files that were compiled by the main file through \include{} commands. So they do not “know” they became part of the big DVI or big SumatraPDF file. What did I miss? It seems that the direct search might work only if Miktex (I used the V2.8) has a way to tell the included files that they were actually “latextified”. Hope I do not burden you with a too difficult question. I can of course default to pouring all the files into the main file if there is no solution. Thanks • You do need to set the main file as the “main file” in WinEdt. Then it should work fine. • Lily I am using WinEdt 6.0 and MikTeX 2.8 on Vista. After I downloaded Sumatrapdf reader, I went to Options/Execution Modes/PDFViewer following your instruction, but the tab for Sumatra PDF is in shadow and does not respond when I click on it. It seems that WinEdt cannot detect Sumatrapdf reader. After I manually changed the Pdf View Executable to D:\Program Files\Sumatrapdf, it indeed worked for the direct and inverse search which is great. But some other packages like hyperref don’t work. Any comment will be appreciated. Thanks • Strange. I have the same combination (but on Windows 7) and it works for me. Make sure you have Sumatrapdf v1.1 and that it is installed in the default directory. • Fernando Nadal Hello, I have MiKTeX 2.7 and WinEdt 6 running on my PC. I work with PDF files (PDFLaTeX). My TeX sources are organized in folders and subfolders and I use the \import{}{} LaTeX command to include them (I think it has better nested folder support than \include or \input). PDF (Forward) Search doesn’t work because can’t find source TeX files located on subfolders. I have changed 1 line of PDF Search.edt and now it works for me: On the :Sumatra_Running:: section change this: DDEExe(‘[ForwardSearch(“%P\%N.pdf”,”%q%n%t”,%!l,0)]’); with this: DDEExe(‘[ForwardSearch(“%P\%N.pdf”,”%p\%n%t”,%!l,0)]’); The change, %p\%n%t, gets the absolute path of the file, that’s all. I hope this can help some one else. • Matthew I have a question that correlates to this thread….when I click PDFTexify, I end up with the PDF in my directory, but it does not ‘auto-launch’ in Adobe, as I have seen in other setups…how do I make the PDF launch right away without having to search for it and open it? • Are you sure you are clicking PDFTeXify? Clicking PDFLaTeX will have the effect you describe. But PDFTeXify should also run the viewer. You can check the settings under Options/Execution Modes/Console Applications. • salein Thank you very much, This is an excellent tutorial! Thanks for putting it up, its really helped me out! François Salein (France) • Stefan Thank you! It works great. • Peter I use winedt 6.0 and Miktex 2.9 my forward syncronizing does’t work. Can you please give me some hint what can be wrong. Before I had Miktex 2.8 with the same problem. It sholud be trivial but….not for me. • Not without more information. It works for me. • Daniel L Step 1 and Step 2 works flawless with WinEdt6, MikTex 2.9 and Sumatra, but only if NO SPACES are available in the file names!! Would you consider adding that to the otherwise brilliant instructions. (Spaces did work with the old “pdfsync” package thus some conversion bugs might appear if not the spaces are considered) • Han Lin Shang I have spent some time to setup the reverse-search of Sumatra-Find in WinEdt 6.0 under Windows 7. I have put the procedures below in hope to help others. In WinEdt 6.0, the menu setup is in Option/Options Interface/Menus and Toolbars/Main Menu/Accessories You should see a file called MainMenu.ini Then, copy and paste this somewhere under the Accessories. ITEM=”Sumatra Find” CAPTION=”&Sumatra Find” MACRO=”Exe(‘%b\Exec\Sumatra-Find.edt’);” SHORTCUT=”Shift+F8″ This should allow the reverse-search work. • Han. This is not necessary if you have the latest version of SumatraPDF and follow the instructions at the top of my post. • Sun I was to use Tex ouptput dvi->ps->pdf as i have to embedded certain fonts. With the configuration that you have mentioned above, it gives a error “LaTeX Failed to Create a DVI file”. However, for default texify –pdf it works good. Is there any work around for this? • Arthur Thanks for this great how-to. It didn’t work for me at first (WinEdt 5.5, MiKTeX 2.9). The problem for me, as for Peter, was that i have the bad habit of including spaces in my TeX file names! While my files would compile fine before, they would not compile with the option synctex=-1. Eliminating the spaces in file names solved the problem. Thanks again. • Pepe Thanks a lot, it worked almost perfectly! I however stumbled over a minor problem. The forward search works flawlessly. The reverse search works as well, but upon invoking, it opens a new copy of Winedt 6 (in the new copy of Winedt, it opens the corresponding file-tab, and goes directly to the proper place). I just wonder why it didn’t like the copy of WinEdt (with the corresponding file) that was already open. Any ideas? • Fahad I am sorry, I am new to this stuff. I couldnt follow the Step 4, for Winedt 5.6. How to create this macro, could you please explain a little • It’s a whole lot simpler to upgrade to WinEdt 6.0. Failing that, read the WinEdt help about creating macros. • sai Further to my last message I would like to update that, if I comment the line: //Run(‘%$(“AcroRead”); -reuse-instance -inverse-search “”%BWinEdt.exe” “[Open(|%%f|);SelPar(%%l,8);]””‘, ‘%P’);And enable the line:Run(‘C:Program FilesSumatraPDFSumatraPDF-TeX.exe -reuse-instance’,’%P’);

This works. I hope you can give me some idea whats the issue here. Appreciate your help. Thanks.

• It sounds like AcroRead is not resolving to SumatraPDF.

• sai

The Warning is:
Cannot Run -reuse-instance -inverse-search “C:Program….WinEdt.exe …..

WinEdt version# 6
MikTex Version# 2.9

Could you please give a solution to the problem? Thanks.

• Sai

Well its fine now.

“Since version 6, WinEdt uses SumatraPDF as the default PDF viewer if it is installed. It automatically configures forward/inverse-search. The default shortcut for forward search is Shift+F8.” Ref:  william.famille-blu dot org

• Anonymous

Dear Hyndman,

Thanks a lot for the useful information!

I am using WinEdt 6, Win7-64bit and Miktex 2.8. I followed your steps with some another suggestion  in the post.

I am writing a thesis where I have different chapters in different sub-folders but my main file is in the main folder.

For me, when I select some text in the tex file and press F8 it opens the Sumatra pdf but always at same point.

And when I double click on the text in Sumatra pdf it shows (somewhere in the top-left corner ) that “No Syncronization info at this position”.. Can you please provide some suggestions..

Looking forward to hear from you soon
Saurabh

• Make sure you’ve set the switches in pdfTeXify (or whatever you use to compile the file) to
–pdf –tex-option=–synctex=-1

• Anonymous

Hello Mr. Hyndman,

Thanks for your quick reply…. but somehow the whole process is not working accurately/smoothly.

When I go from PDF->TEX: It shows again the same problem “No Syncronization info at this position”. But if I double click on the figure captions then it works quite accurate but otherwise no.

When I go from TEX->PDF :: I am forwarded to the page (same or +/-  1page) but not the exact locations. Is it normal?

Saurabh

• Beregorn88

solved. I need to remove all space in the file’s name

• Ziv Ran

Hi, I have the problem that forward search fails to find the tex file: on pressing forward search, sumatra shows a little box with the message: Unknown source file (filename.tex) where filename.tex is the correct path to the tex file– how come ?

• C.

Hi.
I have WinEdt6.0 and Sumatra v1.9 and MikTech 2.9. I did exactly what is desicribed above (points 1 and 2). But the forward search isn’t working. So if I press Shift+Ctrl+F8, nothing happens.
I have also tried to input the command in the accessories-menu. I can see the item there, but it is grey shaded, so I can’t click on it.
(backward search is ok)
What did I wrong?

Thanks, C.

• It is now nearly three years since I wrote this post, and the combination of WinEdt, SumatraPDF and MikTeX is no longer the best set-up in my opinion. Instead, I now recommend TeXStudio as discussed at
http://robjhyndman.com/researchtips/texstudio/ and
http://robjhyndman.com/researchtips/texstudio-sumatrapdf/.

Consequently I am closing the comments here.