LaTeX inverse search with SumatraPDF

In this article I will explain how the inverse search (or inverse synchronisation if you prefer) may work, in a Windows operating system, between a source document in LaTeX, written via a command line editor, and a PDF reader.

Starting conditions

The starting conditions are the following:

  1. You have just created a draft document in LaTeX language using a command line editor and you want to see the result in PDF.
  2. Assume you are using one of the most efficient and widely used text editing systems: Sublime Text
  3. Of course you have installed a LaTeX specific plugin as, for example, LaTeXTools.
  4. Let’s assume also that you are using, for any reason, the currently most common operating system: MS Windows.

If these conditions are valid then the most efficient method to view the documents compiled in LaTeX is certainly the following: Sumatra PDF Reader.

The typical scenario

At this point someone might ask himself: but when can all those conditions occur?
The typical scenario occurs when you work in an office where you are given a computer with the most widespread operating system in business environments and the standard word processing. You want to use a system much more efficient but you can not install it on your company computer.
You can solve this situation by installing on a portable USB stick a LaTeX distribution, a command line editor and a portable PDF reader.
As a portable PDF reader you will use one of the best free readers, less known than other readers, but equipped with integrated synchronization function; Sumatra PDF Reader.
Yes, I know. There are a lot of free good PDF readers. So: why Sumatra PDF Reader?
The main reason for using this software is its natural predisposition for inverse search and synchronization.

What’s a Inverse Search?

The Inverse Search (or Inverse Synchronization) is the process of searching and synchronizing a specific starting from the compilation result, that is starting from the end to the source text.
The purpose is to quickly go from the final document to the source.
This saves you a huge amount of time on long documents.

Two simple visual examples

You can see two simple snapshots:

  1. First Snapshot: PDF OUT OF SYNC: In the following image the cursor is at the height of Section One in the PDF corresponding to Section Two of the editor: synchronization is not satisfied
  2. Second Shapshot: PDF IN SYNC: In the following image the cursor is at the height of Section One in the PDF corresponding to Section One point also of the editor: synchronization is satisfied

And now the most difficult part, but not too much!

And now let’s see how to connect SumatraPDF to the editor used to compile the LaTeX source code.

All you have to do is to go to Settings/Options: image
If you cannot find the field dedicated to the inverse search you have to launch a preparatory compilation from your source file (in Sublime Text 3: Ctrl+b on Windows or Linux and ⌘+b on OS X).

By default, you should find the following text string (see at the bottom of the image):

Instead of the default string you must insert a string of this kind:

image

Let’s take a look at the command line at the bottom of the picture above: "F:\Sublime Text Build 3143\sublime_text.exe" "%f:%l"

  1. The first part is the path to the executable file (remember that we are using a portable software on an external key).
  2. The second part contains a couple of parameters where: %f points to the TeX source file and %l places the pointer on the line number.
    Of course you have to modify the string by inserting the correct path to your executable.

Now you can go back from the PDF to the source simply by double-clicking with the mouse on any point of the PDF itself.
You’ll se the source scrolling up or down till the matching point of the PDF. That’ s all!

Congratulations! You have started saving a lot of time to review and correct your documents compiled in LaTeX!

Thanks for reading this article

Originally published at my Tumblr account

Comments

  1. PDF is among the most safe methods of sharing file with a number of recipients. It's the greatest format to add a doc to the Web with none worries of copying or tempering of its content material. If you want to learn more about this topic please visit https://2pdf.com/

    ReplyDelete

Post a Comment

Popular posts from this blog

Vim: Cut, Copy and Paste to and from the system clipboard

Vim: searching for text containing a slash or a question mark