Hello list, apologies for sending this again if you already got it, first
time I sent it without a subject and I fear it will be filtered
out, besides being bad manners. I apologize for the oversight.

I'm currently working on PDF-to-source navigation for ConTeXt (using
`mtxrun --script synctex --report`) and I keep seeing mid-page SyncTeX
boxes on floats/captions that are tagged with source line 1 (file start),
even when method=max is set. In my tests, a click near the middle of the
caption then resolves to line 1, while a click a little to the side can
resolve to a useful line (e.g. the line of \stopplacefigure). Visually,
system.synctex.visualize=real shows boxes on those captions, so the
geometry exists. The part I do not understand is the line number.

Questions for those who know the SyncTeX implementation in ConTeXt /
LuaMetaTeX:

- Why do some float/caption related boxes get source line 1 instead of the
line of \startplacefigure, the title/caption text, or \stopplacefigure?
Is that expected for delayed/floating material (position finalized late, so
the input line is no longer available or is reset)?

- With \setupsynctex[state=repeat,method=max] (and context --synctex=repeat
on the command line), should caption/float boxes normally carry a useful
line, or is line 1 still considered correct for some of those nodes?

- Is there a recommended way for tools to interpret such hits (ignore line
1 mid-page, prefer a nearby higher line, etc.), or a setup that improves
tagging for placefigure captions?

I am not asking for editor/UI advice; I would like to understand the
engine-side SyncTeX records, because I'm working on my own implementation
of a ConTeXt VSCode plugin. My results so far are very promising, but this
aspect keeps bugging me.

Minimal example follows (LMTX 2026.10.23 / LuaMetaTeX 2.11.10).

Build with:

context --synctex=repeat mwe-line1.tex


%%%%%%%%%%%% mwe-line1.tex
\setupsynctex[state=repeat,method=max] % Or min

\starttext

Before the float.

\startplacefigure[title={A short caption for SyncTeX}]
\framed[width=8cm,height=3cm,frame=on]{placeholder}
\stopplacefigure

After the float.

\stoptext
%%%%%%%%%%%% end mwe-line1.tex

Observed on the resulting mwe-line1.synctex (page 1, coordinates in pt
after dividing sp by 65536):

A fairly wide box tagged line 1 at about y=256, width about 152 (caption
band).
A smaller box tagged line 10 (\stopplacefigure) at the same y, width about
39.

mtxrun --script synctex --report --direct --console probes (cwd = job
directory):

mtxrun --script synctex --report --direct --console --page=1 --x=315
--y=256 --tolerance=50 mwe-line1.synctex -> "mwe-line1.tex" 1 0

mtxrun --script synctex --report --direct --console --page=1 --x=197
--y=256 --tolerance=50 mwe-line1.synctex -> "mwe-line1.tex" 10 0

So the same caption row contains both a coarse line-1 box and a useful
line-10 box; which one --report returns depends on x.

Any clarification on why line 1 is attached to those caption boxes, and
whether that is intentional for floats, would help a lot.

(I also rebuilt the same MWE with method=min
(\setupsynctex[state=repeat,method=min], still context --synctex=repeat).
That run flushed more SyncTeX objects (16 vs 8) and split the caption into
smaller boxes, but several of those boxes are still tagged with source line
1. The same --report probes still return line 1 at the caption center
(x=315,y=256) and line 10 near the useful box (x=197,y=256). So the line-1
tagging does not appear to be specific to method=max; I used max because it
matches the usual --synctex=repeat/method=max setup and is lighter, but min
reproduces the same --report outcome on this MWE.)

Thank you for your time.

-- 
Andrés Conrado Montoya
[email protected]
http://sesentaycuatro.com
----------------------------------------
Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to