Difference between revisions of "SyncTeX"

From ConTeXt wiki
Jump to navigationJump to search
m (document \enabledirectives[system.synctex])
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
'''SyncTeX''' is a program that puts a lot of anchors in the output file that link to the corresponding position in the source file. This allows you to quickly jump from PDF to source.  
 
'''SyncTeX''' is a program that puts a lot of anchors in the output file that link to the corresponding position in the source file. This allows you to quickly jump from PDF to source.  
  
== MkIV ==
+
== Usage ==
  
In MkIV (since I don't know when) you can run
+
You can use the <code>--synctex</code> switch to enable SyncTeX.
context --synctex jobname
 
to use SyncTeX
 
  
== MkII ==
+
So in MkIV you can run
With a ConTeXt version > 2009.06.13 you can run
+
context --synctex <i>jobname</i>
  texexec --synctex jobname
+
and in MkII you can use
that will create a file <code>jobname.synctex.gz</code>.
+
  texexec --synctex <i>jobname</i>
The command
+
 
  ctxtools --purge --all
+
Alternatively you can add the following command to your MkIV document:
 +
<texcode>
 +
\enabledirectives[system.synctex]
 +
</texcode>
 +
 
 +
This will create a file <code><i>jobname</i>.synctex.gz</code>. The command
 +
  context --purge
 
or next run without --synctex will remove the file again.
 
or next run without --synctex will remove the file again.
  
This file can be used by your editor to display the proper file.
+
This file can be used by your editor and PDF viewer to jump back and forth between the source and the PDF.
  
 
== Editors & Viewers ==
 
== Editors & Viewers ==

Latest revision as of 13:56, 19 March 2015

SyncTeX is a program that puts a lot of anchors in the output file that link to the corresponding position in the source file. This allows you to quickly jump from PDF to source.

Usage

You can use the --synctex switch to enable SyncTeX.

So in MkIV you can run

context --synctex jobname

and in MkII you can use

texexec --synctex jobname

Alternatively you can add the following command to your MkIV document:

\enabledirectives[system.synctex]

This will create a file jobname.synctex.gz. The command

context --purge

or next run without --synctex will remove the file again.

This file can be used by your editor and PDF viewer to jump back and forth between the source and the PDF.

Editors & Viewers

TeXWorks

You may need to modify the command for executing ConTeXt first (you need to add --synctex switch in preferences).

Evince

Evince (the GNOME PDF viewer) supports SyncTeX since version 2.32.0.

Skim.app & TextMate (Mac OS X)

In Skim/Preferences/Sync choose TextMate. The key combination

Shift + Apple + MouseClick

will bring you to the corresponding line in text editor.

In TextMate I have created my own command inside the ConTeXt bundle:

  • Save: Nothing
  • Command(s)
#!/bin/bash
pdf=${TM_FILEPATH%tex}pdf
/Applications/Skim.app/Contents/SharedSupport/displayline -r "$TM_LINE_NUMBER" "${pdf}"
  • Input: None
  • Output: Discard
  • Activation: Key Equivalent (choose one; I used Ctrl+Alt+Apple+O)
  • Scope Selector: text.tex.context

If you use Apple+R for typesetting that needs to be modified as well (to account for --synctex switch).

Hopefully this functionality will become part of the official ConTeXt bundle one day. (The recipe given above is too specific. The code needs to be written to handle more different viewers and different locations, not only a single viewer at a specified location.)