Wednesday, August 5, 2009

Setting up TeXlipse and Sumatra PDF


Update (24-03-2012)
Instead of going through the hassle of configuring SumatraPDF (steps 4-8 below), it's way easier to use the Eclipse PDF viewer PDF4Eclipse. It's specifically written for TeXlipse, and has forward- and inverse-search out-of-the-box.


After raving about how brilliant TeXlipse is, it's perhaps time to describe my actual LaTeX setup on Windows. The key ingredients are:
  • LaTeX distribution: MikTeX. I currently have version 2.7 installed, which has SyncTeX support (important for forward- and inverse-searching in PDF files). I haven't tried TeX Live, but that should in principle also work (it also has SyncTex support).
  • Editor: Eclipse + TeXlipse.
  • Previewer: Sumatra PDF. Yes, that's right, no DVI files for me!
Installation is a bit difficult, but worth the while. Here's how you do it:
  1. Download and install MikTeX 2.7 (or newer if you're up for it). Shouldn't be too difficult.
  2. Get a good version of Eclipse. A bit more difficult, since there are gazillion versions floating on the internet. The standard ones come with support for either C++ or Java, which we don't want. The cleanest distribution I could find is the Platform Runtime Binary. Download it and extract the zip file in C:\Program Files\ or the likes. Also put a shortcut to eclipse.exe on the desktop if you're lazy like me.
  3. Fire up Eclipse and follow the instructions on the TeXlipse website in order to install TeXlipse.
  4. Download and install Sumatra PDF. Also easy.
  5. And now the going gets though: it's time to configure TeXlipse. Luckily the TeXlipse folks also have a page for that. The extra ingredient from me is to add the switch "-synctex=1" to the pdflatex command, which enables PDF syncing. The pdflatex config should look something like this:
  6. Add a new viewer configuration for SumatraPDF, and make it the top of the list so it's the default viewer. Here's how its config should look:
  7. We're almost done. We still need to configure the inverse search for Sumatra PDF. Create a .BAT file in the Eclipse directory (or somewhere else convenient), with the following line:
    java -classpath "%ECLIPSEDIR%\plugins\net.sourceforge.texlipse_1.3.0\texlipse.jar" net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f %1 -l %2
    There are no hard line breaks here, it's just one single line. Also add a environment variable via Control Panel -> System -> Advanced -> Environment variables -> System variables -> New. The variable name should be "ECLIPSEDIR", its value "c:\program files\eclipse" or wherever you installed Eclipse (both without the quotes).
  8. Configure Sumatra PDF for inverse search by running the command
    SumatraPDF.exe -inverse-search "\"C:\Program Files\eclipse\inverse_search.bat\" \"%f\" %l"
    where you should take care to properly point to the .BAT file you created in the previous step.
And that's it. Now you should be ready to experience all the wonders of the TeXlipse + Sumatra PDF combination. Enjoy!

35 comments:

Post a Comment