Difference between revisions of "SyncTeX"

From Wiki
Jump to navigation Jump to search
m (document \enabledirectives[system.synctex])
m (drop navbox)
(One intermediate revision by one other user not shown)
Line 10: Line 10:
 
  texexec --synctex <i>jobname</i>
 
  texexec --synctex <i>jobname</i>
  
Alternatively you can add the following command to your MkIV document:
+
Alternatively you can add one of the following commands to your MkIV document:
 
<texcode>
 
<texcode>
\enabledirectives[system.synctex]
+
\setupsynctex[state=start,method=min] % clickable words
 +
\setupsynctex[state=start,method=max] % more efficient clickable ranges
 
</texcode>
 
</texcode>
  
This will create a file <code><i>jobname</i>.synctex.gz</code>. The command
+
This will create a file <code><i>jobname</i>.synctex</code>. The command
 
  context --purge
 
  context --purge
or next run without --synctex will remove the file again.
+
or next run without <code>--synctex</code> will remove the file again.
 +
 
 +
To see what became clickable, use one of
 +
<texcode>
 +
\enabletrackers[system.synctex.visualize]
 +
\enabletrackers[system.synctex.visualize=real]
 +
</texcode>
  
 
This file can be used by your editor and PDF viewer to jump back and forth between the source and the PDF.
 
This file can be used by your editor and PDF viewer to jump back and forth between the source and the PDF.
Line 27: Line 34:
 
You may need to modify the command for executing ConTeXt first (you need to add <code>--synctex</code> switch in preferences).
 
You may need to modify the command for executing ConTeXt first (you need to add <code>--synctex</code> switch in preferences).
  
=== Evince ===
+
=== Evince, Okular & Kile ===
Evince (the GNOME PDF viewer) supports SyncTeX since version 2.32.0.
+
Okular (the KDE PDF viewer) and Evince (the GNOME one) support SyncTeX. (The latter since version 2.32.0)
 +
 
 +
To forward something from a text editor to Okular, do
 +
okular --unique '${pdffile}#src:${linenumber} ${texfile}'
 +
 
 +
Kile’s (the KDE TeX IDE) ForwardPDF function should support SyncTeX, but it doesn’t seem to work with ConTeXt at the time of writing
  
 
=== Skim.app & TextMate (Mac OS X) ===
 
=== Skim.app & TextMate (Mac OS X) ===
Line 52: Line 64:
 
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.)
 
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.)
  
{{Installation navbox}}
 
  
 
[[Category:Text Editors]]
 
[[Category:Text Editors]]

Revision as of 11:00, 2 July 2020

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 one of the following commands to your MkIV document:

\setupsynctex[state=start,method=min] % clickable words
\setupsynctex[state=start,method=max] % more efficient clickable ranges

This will create a file jobname.synctex. The command

context --purge

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

To see what became clickable, use one of

\enabletrackers[system.synctex.visualize]
\enabletrackers[system.synctex.visualize=real]

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, Okular & Kile

Okular (the KDE PDF viewer) and Evince (the GNOME one) support SyncTeX. (The latter since version 2.32.0)

To forward something from a text editor to Okular, do

okular --unique '${pdffile}#src:${linenumber} ${texfile}'

Kile’s (the KDE TeX IDE) ForwardPDF function should support SyncTeX, but it doesn’t seem to work with ConTeXt at the time of writing

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.)