Skip to content

SyncTeX: Why it Matters

One of the features of MacTeX 2008 that I was looking forward to was its inclusion of SyncTeX, Jerome Laurens replacement for pdfsync.

There are two ways to call SyncTeX, from the command line and in source. From the command line simply use the argument -synctex=1, and from source include \synctex=1 in the preamble. The former may be preferable if you want to distribute your LaTeX source—that way it will run without errors even by those whose TeX distributions do not include SyncTeX support.

Here is how synchronization worked with pdfsync. A word in your source is associated with a file name and a line number where it occurs. The file name and line number together constituted the input record. That same word as it occurs in the pdf generated from the source is associated with a page number and a location on that page. Together these constituted the output record. Synchronization was achieved by linking the input record with the output record. Moreover this was done by assigning each of these records with a unique tag. This was necessary since while the TeX engine will place a word in the source on some page in the generated pdf and on some location on that page, by the time it has done this, it has “forgotten” the file name and line number. Unique tags were thus required to preserve this information for synchronization. These tags were stored in special data nodes in every pargraph, math display, etc.

There were three problems, however, with this synchronization solution:

  1. The data nodes used by pdfsync could interfere with TeX’s line breaking mechanism and thus affect the layout of the page.
  2. pdfsync was incompatible with certain LaTeX packages. While some could be rewritten to accommodate pdfsync, others could not.
  3. The mapping from the input record to the output record was not one-one, but one-many. So developers of pdf viewers supporting pdfsync had to choose the right mapping from the input record to the output record, and this was not always easy to do.

Instead of using special data notes, SyncTeX exploits kern nodes and glue nodes that are determined early on in TeX’s processing of the source to track the location of a word in the pdf output.

Another advantage of SyncTeX over pdfsync is that SyncTeX also supports dvi and xdv outputs (not that useful for me, but your situation may differ).

The TeXLive distribution, which MacTeX is built upon, is the first implementation of SyncTeX, and both PdfTeX and XeTeX in TeXLive now have SyncTeX support embedded deep within these TeX engines.

{ 2 } Comments

  1. raheel | September 25, 2008 at 10:58 am | Permalink

    Hi Mark, Have you been able to setup Textmate for use with SyncTeX?

  2. Mark Eli Kalderon | September 26, 2008 at 1:45 pm | Permalink

    The LaTeX bundle has included SyncTeX support since TL2008 was in beta. If you grab the latest version of the bundle from the subversion repository, it should work out of the box. As long as your viewer supports SyncTeX as well, that is. The latest version of Skim does.

Post a Comment

You must be logged in to post a comment.
FireStats icon Powered by FireStats