There is a glaring design flaw in TeX or Synctex for location of words.
Given a text in a .tex files:
Blah blah blah. This is a sentence blah! Blah Blah!
The whole paragraph is treated as one unit rather than the individual words.
It turns out that if one adds new lines to each word or line then the syncing works great:
Blah
blah
blah.
This
is
a
sentence
blah!
Blah
Blah!
And we get single word accuracy.
The problem is that it makes reading the tex file pointless and hence it is not a proper solution.
A real solution would be to have the compiler to automatically translate words(or lines) in to separate lines automatically.
This would provide the proper syntex for word or line resolution but the back propagation would not match the original unaltered .tex file.
The line info would need to be kept track of and then inversely mapped.
Is there any way to do this easily?
e.g.,
Line1:
Blah blah blah. This is a sentence blah! Blah Blah!
Line2:
becomes
Line1:
Blah
Line 2:
blah
Line 3:
blah.
Line 4:
This
Line 5:
is
Line 6:
a
Line 7:
sentence
Line 8:
blah!
Line 9:
Blah
Line 10:
Blah!
And these inserted new lines positions are then kept track of to do the inverse map back in to the column that they were inserted from.
This is all basic mapping and pretty easy do to with a few lines of code except for a few problems.
1: One must not insert new lines in invalid place that will break the .tex file or alter it's output. 2: The editor that responds to the synctex must be able to do the inverse mapping from lines to line/col.
Essentially one could insert a new line in every space as long as it won't break the .tex code and would get word level accuracy. This could potentially be done pre-compilation if proper word boundaries could be determined. I think though it would be better if it could be done in an environment such as
\begin{synctexing}
…
\end{synctexing}
which would essentially add the new lines to all the text in between and ignore any environments inside so things like tikz pictures could be inserted without having to create a bunch of environments.
It would simply output the mapping file(line/col to line) and the editor would have to be able to reverse the map(easy but it would require supporting it unless they already support columns(but that synctex just always gives them 0).
The problem is not that this is difficult but about the specifics which I know nothing about.
In fact, even if we had to do something like \snl
which adds a new line to the synctex, it would be better than nothing.