TeXlipse and SumatraPDF


For several years now, I have been using TeXnicCenter for editing my LaTeX files and most of the time Sumatra PDF for viewing them. The big benefit of Sumatra PDF is its excellent support for forward and inverse search. Double-clicking a line in TeXnicCenter highlights the according line in Sumatra PDF (forward search) and double-clicking a line in Sumatra PDF moves the curser to the according line in TeXnicCenter (inverse search).

I am a Java programmer with my favourite IDE being Eclipse and it would be great to not only write the code but also other documents in the IDE which I am so familiar with. There is an Eclipse plugin, TeXlipse, for the purpose of editing LaTeX. I once tried it, but was not convinced to use it. Anyway, I decided to give it a new try. So far, the syntax highlighting looks far superior and also the additional functions seem to be more mature and comfortable, i.e. auto-compilation, auto-completion and display of warnings and errors works like a charm, but I am still gathering experience with it.

My first step was to configure forward and inverse search with Sumatra PDF for TeXlipse. I know there is a built in PDF viewer provided by the TeXlipse team, but at the time of writing its functionality seems quite limited, when compared to Sumatra PDF. Of course, that might change in a few months. Configuring Sumatra PDF with TeXlipse was not really trivial which is why I am writing this post. There are several blog posts on this subject, but none of the ones I found was up to date, so one more post might do no harm. Currently I use Eclipse Indigo, TeXlipse 1.5.0 and Sumatra PDF 1.9.

(EDIT 07.11.2012: Just verified this with Eclipse Juno 4.2.1, TeXlipse 1.5.0 and SumatraPDF v2.1.1. The tutorial still works, with adjusted file paths of course.)

After installing everything, you need to configure both, TeXlipse and Sumatra PDF to support forward and inverse search. The first step is pdflatex in TeXlipse.
In Eclipse, go to Window->Preferences->Texlipse->Builder Settings, select PDfLatex program and click “Edit…”. The following dialog appears:

PdfLatex Edit Dialog

The crucial aspect here is the argument configuration where you need to change the default argument -synctex=1 %input to -synctex=-1 %input, i.e. 1 to -1.
Next, you need to go to the “Viewer Settings” and modify the existing sumatra PDF entry or create a new one. The dialog looks as follows:

Sumatra Viewer Settings

In this dialog, first select your Sumatra PDF executable. To ensure that only a single instance of Sumatra PDF is opened per document, set the viewer arguments to -reuse-instance %fullfile. The default settings here are set to just %file which does not work. To enable forward search, put the following into the “DDE message to send on view” Command: [ForwardSearch("%fullfile","%texfile",%line, 0,0,1)] which also deviates from the default setting. Server and topic options are correct in the default configuration, but you need to set the Inverse search support option to “Viewer runs external command” and enable the “Viewer supports forward search” checkbox.

So much for TeXlipse, now also Sumatra PDF needs some configuration. Since Sumatra PDF 1.8, it is possible to configure inverse search via the Settings->Options menu. Here is the dialog:

Sumatra Options Dialog

In this dialog, you need to set the command that is executed when activating inverse search. In my sample environment, this command reads as follows:
javaw -classpath "C:\Users\joerg\Desktop\eclipse-3.7.1\eclipse\plugins\net.sourceforge.texlipse_1.5.0\texlipse.jar" net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f %f -l %l
The command executes TeXlipse with appropriate options. For the command to work, you need to set the classpath to the directory of your Eclipse/TeXlipse distribution. -p marks the port over which TeXlipse and Summatra PDF communicate, the default is 55000. -f marks the file and -l the line for which inverse search was activated.

EDIT 08.08.2016: And even after many years, the tutorial still seems to work. I’d like to make one amendment based on an anonymous comment below: If the file you are using includes something in its path with which Windows might have problems (say, a space character), you should enclose the parameter in double quotes, e.g.:

javaw -classpath “C:\Users\joerg\Desktop\eclipse-3.7.1\eclipse\plugins\net.sourceforge.texlipse_1.5.0\texlipse.jar” net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f “%f” -l %l

Advertisements

37 thoughts on “TeXlipse and SumatraPDF

  1. It’s important to note, that you need to start SumatraPDF from within Eclipse (Preview PDF). Otherwise the option for inverse search won’t show up. At least on version 1.9.

  2. Also, if you are on 64-bit windows and using 64-bit Eclipse be sure to use it with 64-bit SumatraPDF or else inverse search won’t work

    1. There should be an entry for Adobe reader in the viewer settings as well, but I don’t know if or what kinds of customizations it requires. Its failure to support forward/inverse search was what made me switch to SummatraPDF some years ago. I don’t know if that has changed.

  3. For me to get this to work I had to put the file in parenthesis in the last step:
    javaw -classpath “C:\eclipse\plugins\net.sourceforge.texlipse_1.5.0\texlipse.jar” net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f “%f” -l %l

  4. Thank you very much for this tutorial – it makes my writing much easier!
    I have an unrelated question regarding texlipse, maybe you can assist:
    Texlipse doesn’t close \{ and doesn’t know \lbrace. Hence when I write sets (which I do a lot), I don’t enjoy auto-closing of the curly parenthesis. Do you know of a workaround? I can solve it by changing the plugin code, but i don’t know how to compile it and connect it to eclipse.

    Thankks!

  5. I had to add the whole path to javaw ($java_install_dir\jdk1.7.0_51\jre\bin\javaw.exe). Didn’t run without it.

    Using Win 8 64 bit#

    Thanks for tutorial though ;)

    1. This depends on whether you have Java in your $path environment variable or not. I had it included anyways, so I didn’t need to add the full path here. Thanks for helping to clarify this!

    2. Hey! I am also using Win8, 64 bit. Could you please share the complete line which you entered in Sumatra inverse search. I have been trying to setup inverse search from last week but its not working. :(

      1. This one works in Win 8-64 bit
        C:\Program Files (x86)\Java\jre7\bin\javaw.exe -classpath “C:\Program Files (x86)\Eclipse\plugins\net.sourceforge.texlipse_1.5.0\texlipse.jar” net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f “%f” -l %l

        Also, put %fullfile for the viewer arguments within quotes, like this: “%fullfile”. This is done to avoid multiple instances of SumatraPDF [already stated by Han in one of the comments below]

  6. Thank your for this tutorial!
    I am working with
    eclipse Kepler 4.3.2
    Texlipse 1.5.0
    SumatraPDF v2.5.2

    My workflow is latex -> dvips -> ps2pdf instead of pdflatex

    In the forward search command, I had to change %texfile to %fulltexfile:
    [ForwardSearch(“%fullfile”,”%fulltexfile”,%line, 0,0,1)]

    Otherwise SumatraPDF displays the error message
    “Unknown source file (myfilename.tex)”

    Forward search works when using STRG+4 for preview. The correct line is highlighted.

    What’s still a bit confusing is, that forward search via ALT_GR + F doesn’t work. It displays
    “The position could not be found in any currently open pdf file”.

    1. You’re welcome! Things always change a little between versions and there certainly are multiple ways to get things working. Right now, I have the same software setting as you and, interestingly, forward search works with pdflatex and a DDE command that is completely empty. ALT_GR + F also doesn’t work for me, but I hadn’t yet heard that you can use this command for forward search?

      1. Ctl+Alt+F does forward search for Pdf4Eclipse provided that the pdf is already open in the internal eclipse pdf viewer provided by Pdf4Eclipse. Then the error message “The position could not be found in any currently open pdf file” is not displayed and the forward search works nicely. This command is only available when the pdf4Eclipse plugin is installed and seems to be specific to Pdf4Eclipse.

        Ctl+4 works for SumatraPdf.

        You can use both! It’s probably easier to just use pdf4Eclipse – you don’t need to jump out of eclipse, just switch editor/viewer in eclipse. But Sumatra is of course more advanced if you’re happy to switch windows or have enough screen space for both.

      2. Hi Rod,
        thanks for the clarification and full aggreement from my side. Since I have two 24-inch screens here, I am more than happy with Eclipse and Sumatra instead of pdf4Eclipse :)

  7. When using a path with spaces in it, for the .pdf (and the project as well), I had to enclose the %fullfile for the viewer arguments within quotes, like this: “%fullfile”. Otherwise, multiple instances of SumatraPDF tried to open files at non-existing locations.

    It’s probably because I have an English version of Windows.

  8. Its important to use the “right way” of invoking SumatraPDF: the Eclipse-side counterpart for listening to and interpreting the messages from SumatraPDF only starts up correctly if you open the PDF-viewer via “Launch the previer (Ctrl+4)” button of the Texlipse plugin. Otherwise all communication attempts are in vain.

  9. Thank you so much. I didn’t even know this was possible. I was just googling for TeXlipse + Sumatra because I heard Sumatra does not lock the file as the Adobe Reader does because this was really annoying me. And through pure luck I found your post! This helps me so much.

      1. I now used your descriptions multiple times in the last two years. Every time when I setup a new machine or even only Eclipse or need to help a friend I search for this again and am really glad it exists! :)

          1. Many thanks! I am glad that this helps so many people and the post will continue to exist with a stable link.

            I have to admit that I switched to TeXstudio and its integrated pdf viewer these days. That editor is more light-weight and you can avoid all the kind of setup like the one described in this post. This is perfect for small paper projects. My Ph.D. thesis, however, was written with TeXlipse and Sumatra, exactly as described above.

  10. Thank you for the tutorial!
    Just an update.
    I’m using the following:
    – Eclipse Luna Service Release 1 (4.4.1)
    – Texlipse 1.5.0
    – Windows 8.1

    The tutorial should be updated to include the double quotes around the %f argument in the Sumatra configuration.
    That is:
    javaw -classpath “C:\Users\joerg\Desktop\eclipse-3.7.1\eclipse\plugins\net.sourceforge.texlipse_1.5.0\texlipse.jar” net.sourceforge.texlipse.viewer.util.FileLocationClient -p 55000 -f “%f” -l %l

    1. Thanks for your comment! I’ll bet this is necessary if the file path includes things that Windows has problems dealing with on a command line level (such as spaces in the path). I added a paragraph with your suggestion to the blog post.

      Regards
      Jörg

  11. In case others are like me—lazy—and tried to copy and paste the inverse search command into sumatraPDF, beware of the smart quotes! You’ll need to change them to standard double-quotes in order for the inverse search to function.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s