I can't get synctex working with ConTeXt MkIV. A .synctex file is generated, but I don't get any syncing in either TeXShop or in Texpad. MkII works.

Here are the details: I'm typesetting the simplest document.

  This is my {\em first} ConTeXt document.

In TeXShop I'm using two engines, one for the TexLive installation:

set path= ($path /usr/texbin /usr/local/bin)
mtxrun --script context --autogenerate --synctex=1 "$1"

and one for the stand alone ConTeXt Suite (system wide instal).

set path= (/Applications/context/tex/texmf-osx-64/bin)
mtxrun --script context --autogenerate --synctex=1 "$1"

Both generate a .synctex file, but TeXShop doesn't sync. Everything is great if I typeset with MkII using the engine:

set path= ($path /usr/texbin /usr/local/bin)
texexec --synctex=1 "$1"

However, I need to use MkIV for real work.

I also tried in Texpad using the build script:

export PATH=/Applications/context/tex/texmf-osx-64/bin:$PATH
mtxrun --script context --autogenerate --synctex=1 "$TEXPAD_ROOTFILE"

That also generates a .synctex file but the syncing doesn't work.

The .log file says "> synctex functionality is enabled, expect 5-10 pct runtime overhead!"

Any ideas? Thanks!


  • 1
    I remember that there was something on the mailing list about this some time ago: \setupsynctex[state=start,method=min] % or method=max mailman.ntg.nl/pipermail/ntg-context/2019/094642.html Jul 14 '19 at 4:27
  • 2
    That put me on the path to a solution. Adding the line: % !TEX useOldSyncParser to my source solves the problem in TeXShop. The line is read when the file is opened, so after adding the line the file must be closed and opened again. This only works in TeXShop. I'll provide detailed answer in a couple days when I've been able to test it more carefully.
    – Gavin
    Jul 15 '19 at 2:55

I do not know if there is a solution for Texpad, or a more general solution, but the solution for TeXShop is simple. Add the line

% !TEX useOldSyncParser

to the beginning of the source.tex file. This line tells TeXShop that the source.synctex file produced by ConTeXt uses an older standard for synctex. Since TeXShop reads that line when the file is opened, adding the line does nothing until source.tex is closed and reopened. Then typeset and syncing works great.

I also added the line that Henri suggested and removed the --synctex=1 flag from the TeXShop engine. This is not related to the syncing issue I was having, but it allows better control of synctex.

I'm not sure why synctex and ConTeXt don't get along better. Richard Koch, the developer of TeXShop, suggests that it as a case of unfortunate timing. "In 2017, [Jérôme] Laurens substantially rewrote both engine synctex support and the synctex_parser." Simultaneously, "the author of ConTeXt, Hans Hagen, wrote his own synctex code for ConTeXt, based unfortunately on the 2016 version of synctex." (release notes to TeXShop 3.89) In the Hagen's book "Workflows" it sounds like his version of synctex may be designed to behave somewhat differently in order to deal with the unique demands of ConTeXt, so that may also have contributed to the situation. I'm not sure.

Now I'm very happy with TeXShop, ConTeXt, and synctex. Thanks Henri, Richard, Hans, and Jérôme!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.